home *** CD-ROM | disk | FTP | other *** search
/ Windows News 2010 Summer - Disc 1 / WN_Ete2010_CD1.iso / Onglet5 / Weezo / Weezo setup.exe / {code_appDir} / www / js / wz_dragdrop-src.js < prev    next >
Text File  |  2010-05-19  |  71KB  |  2,378 lines

  1. /* This notice must be untouched at all times.
  2.  
  3. wz_dragdrop.js    v. 4.85
  4. The latest version is available at
  5. http://www.walterzorn.com
  6. or http://www.devira.com
  7. or http://www.walterzorn.de
  8.  
  9. Copyright (c) 2002-2003 Walter Zorn. All rights reserved.
  10. Created 26. 8. 2002 by Walter Zorn (Web: http://www.walterzorn.com )
  11. Last modified: 10. 2. 2006
  12.  
  13. This DHTML & Drag&Drop Library adds Drag&Drop functionality
  14. to the following types of html-elements:
  15. - images, even if not positioned via layers,
  16.   nor via stylesheets or any other kind of "hard-coding"
  17. - relatively and absolutely positioned layers (DIV elements).
  18. Moreover, it provides extended DHTML abilities.
  19.  
  20. LICENSE: LGPL
  21.  
  22. This library is free software; you can redistribute it and/or
  23. modify it under the terms of the GNU Lesser General Public
  24. License (LGPL) as published by the Free Software Foundation; either
  25. version 2.1 of the License, or (at your option) any later version.
  26.  
  27. This library is distributed in the hope that it will be useful,
  28. but WITHOUT ANY WARRANTY; without even the implied warranty of
  29. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  30.  
  31. For more details on the GNU Lesser General Public License,
  32. see http://www.gnu.org/copyleft/lesser.html
  33. */
  34.  
  35. /*
  36.  * Modified by Nicolas Bruley / Peer 2 World / Weezo from march, 1st 2006
  37.  *
  38.  * Main changes :
  39.  *    added windows object (see win.js and winClient.js scripts for use)
  40.  *  added "receiver" i.e. target for drop
  41.  *  added "elastic drag" : dragged item goes back to initial position when dropped
  42.  *
  43. */
  44.  
  45. // Mouse x and y position and button state, updated by updateMousePosition() function
  46. var mouseX,mouseY,mouseEvt,mouseVX,mouseVY,mousePosT;
  47.  
  48.  
  49. // PATH TO THE TRANSPARENT 1*1 PX IMAGE (required by NS 4 as spacer)
  50. var spacer = '/gfx/b.gif';
  51.  
  52. //Name / id of current highlighted dropTarget
  53. var cDT=null;
  54.  
  55. // id of current highlighted receiver only Target
  56. var currentReceiverOnlyTarget=null;
  57.  
  58. // Class of current dropTarget (unused yet)
  59. var currentDropTargetClass=null;
  60.  
  61. // used to cancel onclick on dragged div
  62. var dragCancelOnclick=false;
  63.  
  64. // Indicate if an object is beeing dragged
  65. var dragInProgress=false;
  66.  
  67. // Indicate if an object is beeing resized
  68. var resizeInProgress=false;
  69.  
  70. // min time between pick and drop to fire preDrop function
  71. var dragMinTimeForPreDrop=0;
  72.  
  73. var winInertiaTimeout=false;
  74.  
  75. // Optional commands passed to SET_DHTML() on the html-page (g: may be applied globally, i: individually)
  76. var CLONE            = 'C10nE';   // i  img      clone image
  77. var COPY             = 'C0pY';    // i  img      create copies
  78. var DETACH_CHILDREN  = 'd37aCH';  // i  lyr      detach images
  79. var HORIZONTAL       = 'H0r1Z';   // i  img,lyr  horizontally draggable only
  80. var MAXHEIGHT        = 'm7x8I';   // i  img,lyr  maximum height limit, "
  81. var MAXOFFBOTTOM     = 'm7xd0wN'; // i  img,lyr  downward offset limit
  82. var MAXOFFLEFT       = 'm7x23Ft'; // i  img,lyr  leftward offset limit
  83. var MAXOFFRIGHT      = 'm7x0Ff8'; // i  img,lyr  rightward offset limit
  84. var MAXOFFTOP        = 'm7xu9';   // i  img,lyr  upward offset limit
  85. var MAXWIDTH         = 'm7xW1';   // i  img,lyr  maximum width limit, use with resizable or scalable
  86. var MINWIDTH         = 'm1nw1';   // i  img,lyr  minimum width limit, "
  87. var MINHEIGHT        = 'm1n8I';   // i  img,lyr  minimum height limit, "
  88. var NO_ALT           = 'no81T';   // gi img      disable alt and title attributes
  89. var NO_DRAG          = 'N0d4Ag';  // i  img,lyr  disable draggability
  90. var RESET_Z          = 'r35E7z';  // gi img,lyr  reset z-index when dropped
  91. var RESIZABLE        = 'r5IZbl';  // gi img,lyr  resizable if <ctrl> or <shift> pressed
  92. var RESIZABLE_ONLY    = 'r5IZbl0';  // gi img,lyr  resizable without <ctrl> or <shift> pressed, not draggable
  93. var AUTOSIZE    = 'oTo5iZ3';  // width & height not fixed
  94. var FROZEN    = 'Fr023n';  // Item cannot be dragged or picked while frozen. Use .warm to cancel
  95. var SCALABLE         = 'SCLbl';   // gi img,lyr  scalable           "
  96. var SCROLL           = 'sC8lL';   // gi img,lyr  enable auto scroll functionality
  97. var TRANSPARENT      = 'dIApHAn'; // gi img,lyr  translucent while dragged
  98. var VERTICAL         = 'V3Rt1C';  // i  img,lyr  vertically draggable only
  99. var INERTIA         = '1nRt14';  // i  img,lyr inertia when item dropped
  100. var NOBOUNCE    = 'n08oVnC3'; // inertia object doesn't bounce on borders
  101. var ROT    = 'r0T';               // object may be rotated
  102. var DETACH         = 'd3T4cH';  // detach object from parent when draggin (to be used when object has overflow:scroll/auto/hidden)
  103. var DETACHOFFSETX = 'd3T4cH0ff53Tx' // x-offset of detached object (use with DETACH to correct object offset when moved to parent)
  104. var DETACHOFFSETY = 'd3T4cH0ff53Ty' // y-offset of detached object (use with DETACH to correct object offset when moved to parent)
  105. var EPHEMERAL = '3ph3M3ra1' // Object is destroyed when dropped
  106. var DRAGCLASS = 'Dr465Ty1E' // Add "dragged" to class when dragged
  107. var PICKDELAY        = 'PlcKD31Ay' // Time (ms) mouse button must be kept down to pick the object
  108. var RECEIVER         = 'R3C31vR';  // drop target
  109. var ELASTIC            = '3LAsT1C'; // Elastic drag
  110. var NOANIM      = 'n0An1M' // No animation when droppεng an elastic object
  111. var NOTDROPPABLE        = 'N0tDr0dA813'; // Not droppable item (doesn't highlight drop zones)
  112. var TRANSPARENT_RECEIVER = 'TrAn5PaRenT'; // drop target becomes transparent when dragged over.
  113. var CTRLPLUS = 'cTRlPlV5'; // Add a plus next to the dragged item if ctrl pressed while draggin
  114. var ISWINDOW = '15W1nD0w'; // Window
  115. var ISICON = '15W1c0n'; // Icon
  116. var IMGFADEIN = '1mA63FaD1n'; // Fade-in images onload
  117.  
  118. var dd_cursors = new Array(
  119.     'c:default',
  120.     'c:crosshair',
  121.     'c:e-resize',
  122.     'c:hand',
  123.     'c:help',
  124.     'c:move',
  125.     'c:n-resize',
  126.     'c:ne-resize',
  127.     'c:nw-resize',
  128.     'c:s-resize',
  129.     'c:se-resize',
  130.     'c:sw-resize',
  131.     'c:text',
  132.     'c:w-resize',
  133.     'c:wait');
  134.  
  135. var dd_i = dd_cursors.length; while(dd_i--)
  136.     eval('var CURSOR_' + (dd_cursors[dd_i].substring(2).toUpperCase().replace('-', '_')) + ' = "' + dd_cursors[dd_i] + '";');
  137. var dd_u = "undefined";
  138.  
  139. // receiver-only objects array
  140. function WDD(){
  141.     this.elements = new Array(0);
  142.     this.currentTarget=null; // Currently highlighted element
  143.     this.currentTargetClass=''; // Currently highlighted element previous class
  144. }
  145. var drec=new WDD()
  146. drec.addElt=function(obj){drec.elements[obj.id] = obj;}// Add DOM node to receiver-only list
  147. drec.delElt=function(obj){if(obj.id && drec.elements[obj.id]) delete(drec.elements[obj.id]);} // Remove DOM node from list
  148. drec.setScrollContainer=function(obj,item){drec.elements[obj.id].scrollContainer=item} // Function called when hovering item for over timeout ms
  149. drec.setHighlightFunction=function(obj,func){drec.elements[obj.id].highlightFunc=func}
  150.  
  151. drec.addTimeoutFunc=function(obj,func,timeout){drec.elements[obj.id].toFunc=func;drec.elements[obj.id].timeout=timeout} // Function called when hovering item for over timeout ms
  152. drec.computeRect = function (){for(i in drec.elements) drec.elements[i].rect=actualRect(drec.elements[i]);}
  153. drec.highlight = function (obj){
  154.     drec.currentTarget=obj;
  155.     if(drec.elements[obj.id].highlightFunc) return drec.elements[obj.id].highlightFunc(obj,1);
  156.     // Save class
  157.     drec.currentTargetClass=obj.className;
  158.     obj.className='dropTargetOver '+obj.className
  159.     // Timeout function
  160.     if(drec.elements[obj.id].toFunc){
  161.         drec.elements[obj.id].wTimeout = W.setTimeout(drec.elements[obj.id].toFunc,drec.elements[obj.id].timeout)
  162.     }
  163. }
  164. drec.unhighlight = function (){
  165.     if(drec.currentTarget==null) return;
  166.     // Cancel timeout function
  167.     if(drec.currentTarget.wTimeout) {W.clearTimeout(drec.currentTarget.wTimeout); drec.currentTarget.wTimeout=false}
  168.  
  169.     // Reset class
  170.     if(drec.currentTarget.highlightFunc) drec.currentTarget.highlightFunc(drec.currentTarget,0);
  171.     else if(drec.currentTarget.className.substr(0,14)=='dropTargetOver') drec.currentTarget.className=drec.currentTarget.className.substr(14).trim();
  172.     //else drec.currentTarget.className=drec.currentTargetClass;
  173.     drec.currentTarget=null
  174. }
  175.  
  176. function WZDD()
  177. {
  178.     this.elements = new Array(0);
  179.     this.obj = null;
  180.     this.n = navigator.userAgent.toLowerCase();
  181.     this.db = (D.compatMode && D.compatMode.toLowerCase() != "backcompat")?
  182.         D.documentElement
  183.         : (D.body || null);
  184.     this.op = !!(W.opera && D.getElementById);
  185.     if(this.op) D.onmousedown = new Function('e',
  186.         'if(((e = e || W.event).target || e.srcElement).tagName == "IMAGE") return false;');
  187.     this.ie = !!(this.n.indexOf("msie") >= 0 && D.all && this.db && !this.op);
  188.     this.ie7 = !!(this.n.indexOf("msie 7.0") >= 0 && D.all && this.db && !this.op);
  189.     this.ie8 = !!(this.n.indexOf("msie 8.0") >= 0 && D.all && this.db && !this.op);
  190.     this.iemac = !!(this.ie && this.n.indexOf("mac") >= 0);
  191.     this.ie4 = !!(this.ie && !D.getElementById);
  192.     this.n4 = !!(D.layers && typeof D.classes != dd_u);
  193.     this.n6 = !!(typeof W.getComputedStyle != dd_u && typeof D.createRange != dd_u);
  194.     this.w3c = !!(!this.op && !this.ie && !this.n6 && D.getElementById);
  195.     this.ce = !!(D.captureEvents && D.releaseEvents);
  196.     this.px = this.n4? '' : 'px';
  197.     this.tiv = this.w3c? 40 : 10;
  198.  
  199.     this.pickDate = 0; // Date of object pick
  200.     this.delayedPickEvt=null; // Mouse event originating drag, stored for delayed pick
  201.     this.delayedPickTimeout=null; // Timeout used for delayed pick, and also for stating that a delayed pick is in progress
  202.     this.dragTime= 0; // Time (ms) of drag
  203.     this.pickMouseX = this.pickMouseY = 0; // Mouse position when picked
  204.     this.lpDate = 0; // Last Date used for inertia animation
  205.     this.pickX = this.pickY = 0; // x, y position of object when picked
  206.     this.lpx = this.lpy = 0; // Last x, y positions used for inertia animation
  207.     this.lpdx = this.lpdy = this.lpdt = this.lpda = 0; // dx, dy, dt, da used for inertia animation
  208.     this.mPickX=0; this.mPickY=0; // Mouse coordinates on object pick
  209.     this.mDropX=0; this.mDropY=0; // Mouse coordinates on object drop
  210.     this.mdx=0; this.mdy=0; // Mouse move between pick and drop
  211. }
  212. var dd = new WZDD();
  213.  
  214. dd.Int = function (d_x, d_y)
  215. {
  216.     return isNaN(d_y = parseInt(d_x))? 0 : d_y;
  217. };
  218. dd.getWndW = function ()
  219. {
  220.     return dd.Int(
  221.         (dd.db && !dd.op && !dd.w3c && dd.db.clientWidth)? dd.db.clientWidth
  222.         : (W.innerWidth || 0)
  223.     );
  224. };
  225. dd.getWndH = function ()
  226. {
  227.     return dd.Int(
  228.         (dd.db && !dd.op && !dd.w3c && dd.db.clientHeight)? dd.db.clientHeight
  229.         : (W.innerHeight || 0)
  230.     );
  231. };
  232. dd.getPadding = function (){return (W.winPadding)?winPadding:{'left':0,'top':0,'right':0,'bottom':0};}
  233. dd.getScrollX = function ()
  234. {
  235.     return dd.Int(W.pageXOffset || (dd.db? dd.db.scrollLeft : 0));
  236. };
  237. dd.getScrollY = function ()
  238. {
  239.     return dd.Int(W.pageYOffset || (dd.db? dd.db.scrollTop : 0));
  240. };
  241. dd.getPageXY = function (d_o)
  242. {
  243.     if(dd.n4 && d_o)
  244.     {
  245.         dd.x = d_o.pageX || 0;
  246.         dd.y = d_o.pageY || 0;
  247.     }
  248.     else
  249.     {
  250.         dd.x = dd.y = 0; //global helper vars
  251.         while(d_o)
  252.         {
  253.             dd.x += dd.Int(d_o.offsetLeft);
  254.             dd.y += dd.Int(d_o.offsetTop);
  255.             d_o = d_o.offsetParent || null;
  256.         }
  257.     }
  258. };
  259. dd.getCssXY = function (d_o)
  260. {
  261.     if(d_o.div)
  262.     {
  263.         if(dd.n4)
  264.         {
  265.             d_o.cssx = d_o.div.x;
  266.             d_o.cssy = d_o.div.y;
  267.         }
  268.         else if(dd.ie4)
  269.         {
  270.             d_o.cssx = d_o.css.pixelLeft;
  271.             d_o.cssy = d_o.css.pixelTop;
  272.         }
  273.         else
  274.         {
  275.             d_o.css.left = d_o.css.top = 0 + dd.px;
  276.             dd.getPageXY(d_o.div);
  277.             d_o.cssx = d_o.x - dd.x;
  278.             d_o.cssy = d_o.y - dd.y;
  279.             d_o.css.left = d_o.cssx + dd.px;
  280.             d_o.css.top = d_o.cssy + dd.px;
  281.         }
  282.     }
  283.     else
  284.     {
  285.         d_o.cssx = 0;
  286.         d_o.cssy = 0;
  287.     }
  288. };
  289. dd.getImgW = function (d_o)
  290. {
  291.     return d_o? dd.Int(d_o.width) : 0;
  292. };
  293. dd.getImgH = function (d_o)
  294. {
  295.     return d_o? dd.Int(d_o.height) : 0;
  296. };
  297. dd.getDivW = function (d_o)
  298. {
  299.     return dd.Int(
  300.         dd.n4? (d_o.div? d_o.div.clip.width : 0)
  301.         : d_o.div? (d_o.div.offsetWidth || d_o.css.pixelWidth || d_o.css.width || 0)
  302.         : 0
  303.     );
  304. };
  305. dd.getDivH = function (d_o)
  306. {
  307.     return dd.Int(
  308.         dd.n4? (d_o.div? d_o.div.clip.height : 0)
  309.         : d_o.div? (d_o.div.offsetHeight || d_o.css.pixelHeight || d_o.css.height || 0)
  310.         : 0
  311.     );
  312. };
  313. dd.getWH = function (d_o)
  314. {
  315.     d_o.w = dd.getDivW(d_o);
  316.     d_o.h = dd.getDivH(d_o);
  317.     if(d_o.css)
  318.     {
  319.         d_o.css.width = d_o.w + dd.px;
  320.         d_o.css.height = d_o.h + dd.px;
  321.         d_o.dw = dd.getDivW(d_o)-d_o.w;
  322.         d_o.dh = dd.getDivH(d_o)-d_o.h;
  323.         d_o.css.width = (d_o.w-d_o.dw) + dd.px;
  324.         d_o.css.height = (d_o.h-d_o.dh) + dd.px;
  325.     }
  326.     else d_o.dw = d_o.dh = 0;
  327. };
  328. dd.getCssProp = function (d_o, d_pn6, d_pstyle, d_pn4)
  329. {
  330.     if(d_o && dd.n6) return ''+W.getComputedStyle(d_o, null).getPropertyValue(d_pn6);
  331.     if(d_o && d_o.currentStyle) return ''+eval('d_o.currentStyle.'+d_pstyle);
  332.     if(d_o && d_o.style) return ''+eval('d_o.style.'+d_pstyle);
  333.     if(d_o && dd.n4) return ''+eval('d_o.'+d_pn4);
  334.     return '';
  335. };
  336. dd.getDiv = function (d_x, d_d)
  337. {
  338.     d_d = d_d || document;
  339.     if(dd.n4)
  340.     {
  341.         if(d_d.layers[d_x]) return d_d.layers[d_x];
  342.         for(var d_i = d_d.layers.length; d_i--;)
  343.         {
  344.             var d_y = dd.getDiv(d_x, d_d.layers[d_i].document);
  345.             if(d_y) return d_y;
  346.         }
  347.     }
  348.     if(dd.ie) return d_d.all[d_x] || null;
  349.     if(d_d.getElementById) return d_d.getElementById(d_x) || null;
  350.     return null;
  351. };
  352. dd.getImg = function (d_o, d_nm, d_xy, d_w)
  353. {
  354.     d_w = d_w || window;
  355.     var d_img;
  356.     if(D.images && (d_img = d_w.D.images[d_nm]))
  357.     {
  358.         if(d_xy)
  359.         {
  360.             if(dd.n4)
  361.             {
  362.                 dd.getPageXY(d_w);
  363.                 d_o.defx = d_img.x + dd.x;
  364.                 d_o.defy = d_img.y + dd.y;
  365.             }
  366.             else
  367.             {
  368.                 dd.getPageXY(d_img);
  369.                 d_o.defx = dd.x;
  370.                 d_o.defy = dd.y;
  371.             }
  372.         }
  373.         return d_img;
  374.     }
  375.     if(dd.n4) for(var d_i = d_w.D.layers.length; d_i--;)
  376.     {
  377.         var d_y = dd.getImg(d_o, d_nm, d_xy, d_w.D.layers[d_i]);
  378.         if(d_y) return d_y;
  379.     }
  380.     return null;
  381. };
  382. dd.getParent = function (d_o, d_p)
  383. {
  384.     if(dd.n4)
  385.     {
  386.         for(d_p, d_i = dd.elements.length; d_i--;)
  387.         {
  388.             if(!((d_p = dd.elements[d_i]).is_image) && d_p.div && (d_p.div.D.layers[d_o.name] || d_o.oimg && d_p.div.D.images[d_o.oimg.name]))
  389.                 d_p.addChild(d_o, d_p.detach, 1);
  390.         }
  391.     }
  392.     else
  393.     {
  394.         d_p = d_o.is_image? dd.getImg(d_o, d_o.oimg.name) : (d_o.div || null);
  395.         while(d_p && !!(d_p = d_p.offsetParent || d_p.parentNode || null))
  396.         {
  397.             if(d_p.ddObj)
  398.             {
  399.                 d_p.ddObj.addChild(d_o, d_p.ddObj.detach, 1);
  400.                 break;
  401.             }
  402.         }
  403.     }
  404. };
  405. dd.getCmd = function (d_o, d_cmd, d_cmdStr)
  406. {
  407.     var d_i = d_o.id.indexOf(d_cmd), d_j,
  408.     d_y = (d_i >= 0)*1;
  409.     if(d_y)
  410.     {
  411.         d_j = d_i+d_cmd.length;
  412.         if(d_cmdStr) d_o.cmd += d_o.id.substring(d_i, d_j);
  413.         d_o.id = d_o.id.substring(0, d_i) + d_o.id.substring(d_j);
  414.     }
  415.     return d_y;
  416. };
  417. dd.getCmdVal = function (d_o, d_cmd, d_cmdStr, int0)
  418. {
  419.     var d_i = d_o.id.indexOf(d_cmd), d_j,
  420.     d_y = (d_o.id.indexOf(d_cmd) >= 0)? dd.Int(d_o.id.substring(d_o.id.indexOf(d_cmd)+d_cmd.length)) : int0? -1 : 0;
  421.     if(!int0 && d_y || int0 && d_y >= 0)
  422.     {
  423.         d_j = d_i+d_cmd.length+(""+d_y).length;
  424.         if(d_cmdStr) d_o.cmd += d_o.id.substring(d_i, d_j);
  425.         d_o.id = d_o.id.substring(0, d_i) + d_o.id.substring(d_j);
  426.     }
  427.     return d_y;
  428. };
  429. dd.addElt = function (d_o, d_p)
  430. {
  431.     dd.elements[d_o.name] = dd.elements[d_o.index = dd.elements.length] = d_o;
  432.     if(d_p) d_p.copies[d_o.name] = d_p.copies[d_p.copies.length] = d_o;
  433. };
  434. dd.mkWzDom = function ()
  435. {
  436.     var d_o, d_i = dd.elements.length; while(d_i--) dd.getParent(dd.elements[d_i]);
  437.     d_i = dd.elements.length; while(d_i--)
  438.     {
  439.         d_o = dd.elements[d_i];
  440.         if(d_o.children && !d_o.parent)
  441.         {
  442.             var d_j = d_o.children.length; while(d_j--)
  443.                 d_o.children[d_j].setZ(d_o.z+d_o.children[d_j].z, 1);
  444.         }
  445.     }
  446. };
  447. dd.addProps = function (d_o)
  448. {
  449.     var d_i, d_c;
  450.     if(d_o.is_image)
  451.     {
  452.         d_o.div = dd.getDiv(d_o.id);
  453.         d_o.css = (d_o.div && typeof d_o.div.style != dd_u)? d_o.div.style : null;
  454.         d_o.nimg = (dd.n4 && d_o.div)? d_o.div.D.images[0] : (D.images[d_o.id+"NI1m6G"] || null);
  455.         if(!d_o.noalt && !dd.noalt && d_o.nimg && d_o.oimg)
  456.         {
  457.             d_o.nimg.alt = d_o.oimg.alt || '';
  458.             if(d_o.oimg.title) d_o.nimg.title = d_o.oimg.title;
  459.         }
  460.         d_o.bgColor = '';
  461.     }
  462.     else
  463.     {
  464.         d_o.bgColor = dd.getCssProp(d_o.div, 'background-color','backgroundColor','bgColor').toLowerCase();
  465.         if(dd.n6 && d_o.div)
  466.         {
  467.             if((d_c = d_o.bgColor).indexOf('rgb') >= 0)
  468.             {
  469.                 d_c = d_c.substring(4, d_c.length-1).split(',');
  470.                 d_o.bgColor = '#';
  471.                 for(d_i = 0; d_i < d_c.length; d_i++) d_o.bgColor += parseInt(d_c[d_i]).toString(0x10);
  472.             }
  473.             else d_o.bgColor = d_c;
  474.         }
  475.     }
  476.     if(dd.scalable) d_o.scalable = d_o.resizable^1;
  477.     else if(dd.resizable) d_o.resizable = d_o.scalable^1;
  478.     d_o.setZ(d_o.defz);
  479.     d_o.cursor = d_o.cursor || dd.cursor || 'auto';
  480.     d_o._setCrs(d_o.nodrag? 'auto' : d_o.cursor);
  481.     d_o.diaphan = d_o.diaphan || dd.diaphan || 0;
  482.     d_o.opacity = 1.0;
  483.     d_o.visible = true;
  484. };
  485. dd.initz = function ()
  486. {
  487.     if(!(dd && (dd.n4 || dd.n6 || dd.ie || dd.op || dd.w3c))) return;
  488.     else if(dd.n6 || dd.ie || dd.op || dd.w3c) dd.recalc(1);
  489.     var d_drag = (D.onmousemove == DRAG),
  490.     d_resize = (D.onmousemove == RESIZE);
  491.     if(dd.loadFunc) dd.loadFunc();
  492.     if(d_drag) dd.setMovHdl(DRAG);
  493.     else if(d_resize) dd.setMovHdl(RESIZE);
  494.     if(d_drag || d_resize) dd.setUpHdl(DROP);
  495.     dd.setDwnHdl(PICK);
  496. };
  497. dd.finlz = function ()
  498. {
  499.     if(dd.ie && dd.elements)
  500.     {
  501.         var d_i = dd.elements.length; while(d_i--)
  502.             dd.elements[d_i].del();
  503.     }
  504.     if(dd.uloadFunc) dd.uloadFunc();
  505. };
  506.  
  507. dd.setDwnHdl = function (d_x)
  508. {
  509.     if(D.onmousedown != d_x)
  510.     {
  511.         dd.downFunc = D.onmousedown;
  512.         D.onmousedown = d_x;
  513.         D.ontouchstart = d_x;
  514.     }
  515. };
  516. dd.setMovHdl = function (d_x)
  517. {
  518.     if(D.onmousemove != d_x)
  519.     {
  520.         D.onmousemove = d_x;
  521.         D.ontouchmove= d_x;
  522.     }
  523. };
  524. dd.setUpHdl = function (d_x)
  525. {
  526.     if(D.onmouseup != d_x)
  527.     {
  528.         dd.upFunc = D.onmouseup;
  529.         D.onmouseup = d_x;
  530.         D.ontouchend = d_x;
  531.     }
  532. };
  533. dd.setKDwnHdl = function (d_x)
  534. {
  535.     if(D.onkeydown != d_x)
  536.     {
  537.         dd.kDwnFunc = D.onkeydown;
  538.         D.onkeydown = d_x;
  539.     }
  540. };
  541. dd.setKUpHdl = function (d_x)
  542. {
  543.     if(D.onkeyup != d_x)
  544.     {
  545.         dd.kUpFunc = D.onkeyup;
  546.         D.onkeyup = d_x;
  547.     }
  548. };
  549.  
  550. dd.evt = function (d_e)
  551. {
  552.     // iPhone
  553.     if(d_e && d_e.touches){
  554.         this.e=d_e;
  555.         this.button=this.but=d_e['type']=="touchend"?0:1;
  556.         var t=d_e.touches[0];
  557.         if(t){
  558.             this.src=t?t.target:null;
  559.             this.x=t.clientX;
  560.             this.y=t.clientY;
  561.         }
  562.         else{
  563.             this.src=d_e.target;
  564.             this.x=mouseX;
  565.             this.y=mouseY;
  566.         }
  567.         this.modifKey=false;
  568.     }
  569.     // Desktop browsers
  570.     else{
  571.         this.but = (this.e = d_e || W.event).which || this.e.button || 0;
  572.         this.button = (this.e.type == 'mousedown')? this.but
  573.             : (dd.e && dd.e.button)? dd.e.button
  574.             : 0;
  575.         this.src = this.e.target || this.e.srcElement || null;
  576.  
  577.         this.x = dd.Int(this.e.pageX || this.e.clientX || 0);
  578.         this.y = dd.Int(this.e.pageY || this.e.clientY || 0);
  579.         if(dd.ie)
  580.         {
  581.             this.x += dd.getScrollX() - (dd.ie && !dd.iemac)*1;
  582.             this.y += dd.getScrollY() - (dd.ie && !dd.iemac)*1;
  583.         }
  584.         this.modifKey = this.e.modifiers? this.e.modifiers&Event.SHIFT_MASK : (this.e.shiftKey || false);
  585.         this.ctrlKey = this.e.modifiers? this.e.modifiers&Event.CONTROL_MASK : (this.e.ctrlKey || false);
  586.     }
  587.     this.src.tag = ("" + (this.src.tagName || this.src)).toLowerCase();
  588. };
  589.  
  590. // Script load monitoring
  591. if(W.lFunc) lFunc('wz_dragdrop',25);
  592.  
  593. dd.getEventTarget = function (d_e, d_s, d_n)
  594. {
  595.     d_e = d_e || W.event;
  596.     if(d_e && (d_s = d_e.target || d_e.srcElement || null) != null)
  597.     {
  598.         if(null != (d_n = d_s.id || d_s.name || null))
  599.         {
  600.             if(d_n.indexOf("dIi15vNI1m6G") == d_n.length-12)
  601.                 return dd.elements[d_n.substring(0, d_n.length-12)] || null;
  602.             if(d_n.indexOf("dIi15v") == d_n.length-6)
  603.                 return dd.elements[d_n.substring(0, d_n.length-6)] || null;
  604.             return dd.elements[d_n] || null;
  605.         }
  606.     }
  607.     return null;
  608. };
  609. dd.recalc = function (d_x)
  610. {
  611.     var d_o, d_i = dd.elements.length; while(d_i--)
  612.     {
  613.         if(!(d_o = dd.elements[d_i]).is_image && d_o.div)
  614.         {
  615.             dd.getWH(d_o);
  616.             if(d_o.div.pos_rel)
  617.             {
  618.                 dd.getPageXY(d_o.div);
  619.                 var d_dx = dd.x - d_o.x, d_dy = dd.y - d_o.y;
  620.                 d_o.defx += d_dx;
  621.                 d_o.x += d_dx;
  622.                 d_o.defy += d_dy;
  623.                 d_o.y += d_dy;
  624.                 var d_p, d_j = d_o.children.length; while(d_j--)
  625.                 {
  626.                     if(!(d_p = d_o.children[d_j]).detached && (d_o != d_p.defparent || !(d_p.is_image && dd.getImg(d_p, d_p.oimg.name, 1))))
  627.                     {
  628.                         d_p.defx += d_dx;
  629.                         d_p.defy += d_dy;
  630.                         d_p.moveBy(d_dx, d_dy);
  631.                     }
  632.                 }
  633.             }
  634.         }
  635.         else if(d_o.is_image && !dd.n4)
  636.         {
  637.             if(dd.n6 && d_x && !d_o.defw) d_o.resizeTo(d_o.defw = dd.getImgW(d_o.oimg), d_o.defh = dd.getImgH(d_o.oimg));
  638.             var d_defx = d_o.defx, d_defy = d_o.defy;
  639.             if(!(d_o.parent && d_o.parent != d_o.defparent) && (d_x || !d_o.detached || d_o.horizontal || d_o.vertical) && dd.getImg(d_o, d_o.oimg.name, 1))
  640.                 d_o.moveBy(d_o.defx-d_defx, d_o.defy-d_defy);
  641.         }
  642.     }
  643. };
  644. dd.recalcItem = function (d_i){
  645.     if(d_i) d_o=dd.elements[d_i]; else d_o=dd.obj;
  646.     if(!d_o.is_image && d_o.div)
  647.     {
  648.         dd.getWH(d_o);
  649.         if(d_o.div.pos_rel)
  650.         {
  651.             dd.getPageXY(d_o.div);
  652.             var d_dx = dd.x - d_o.x, d_dy = dd.y - d_o.y;
  653.             d_o.defx += d_dx;
  654.             d_o.x += d_dx;
  655.             d_o.defy += d_dy;
  656.             d_o.y += d_dy;
  657.             var d_p, d_j = d_o.children.length; while(d_j--)
  658.             {
  659.                 if(!(d_p = d_o.children[d_j]).detached && (d_o != d_p.defparent || !(d_p.is_image && dd.getImg(d_p, d_p.oimg.name, 1))))
  660.                 {
  661.                     d_p.defx += d_dx;
  662.                     d_p.defy += d_dy;
  663.                     d_p.moveBy(d_dx, d_dy);
  664.                 }
  665.             }
  666.         }
  667.     }
  668.     else if(d_o.is_image && !dd.n4)
  669.     {
  670.         if(dd.n6 && !d_o.defw) d_o.resizeTo(d_o.defw = dd.getImgW(d_o.oimg), d_o.defh = dd.getImgH(d_o.oimg));
  671.         var d_defx = d_o.defx, d_defy = d_o.defy;
  672.         if(!(d_o.parent && d_o.parent != d_o.defparent) && (!d_o.detached || d_o.horizontal || d_o.vertical) && dd.getImg(d_o, d_o.oimg.name, 1))
  673.             d_o.moveBy(d_o.defx-d_defx, d_o.defy-d_defy);
  674.     }
  675. }
  676. dd.elasticAnim = function (objName){
  677.     var obj=dd.elements[objName];
  678.     if(Math.pow(obj.defx-obj.x,2)+Math.pow(obj.defy-obj.y,2)<19){
  679.         obj.moveTo(obj.defx,obj.defy);
  680.         obj.released();
  681.     }
  682.     else{
  683.         obj.moveTo(Math.floor((3*obj.x+obj.defx)/4),Math.floor((3*obj.y+obj.defy)/4));
  684.         setTimeout('dd.elasticAnim("'+objName+'")',1);
  685.     }
  686. }
  687. function WINSZ(d_x)
  688. {
  689.     if(d_x)
  690.     {
  691.         if(dd.n4)
  692.         {
  693.             dd.iW = innerWidth;
  694.             dd.iH = innerHeight;
  695.         }
  696.         W.onresize = new Function('WINSZ();');
  697.         return;
  698.     }
  699.     else if(dd.n4 && (innerWidth != dd.iW || innerHeight != dd.iH)) location.reload();
  700.     else if(!dd.n4) setTimeout('dd.recalc()', 0xa);
  701.     my_winResize();
  702. }
  703. WINSZ(1);
  704.  
  705. function DDObj(d_o, d_i)
  706. {
  707.     this.id = d_o;
  708.     this.cmd = '';
  709.     this.cpy_n = dd.getCmdVal(this, COPY);
  710.     this.maxoffb = dd.getCmdVal(this, MAXOFFBOTTOM, 0, 1);
  711.     this.maxoffl = dd.getCmdVal(this, MAXOFFLEFT, 0, 1);
  712.     this.maxoffr = dd.getCmdVal(this, MAXOFFRIGHT, 0, 1);
  713.     this.maxofft = dd.getCmdVal(this, MAXOFFTOP, 0, 1);
  714.  
  715.     this.receiver = dd.getCmd(this, RECEIVER);
  716.     this.elastic = dd.getCmd(this, ELASTIC);
  717.     this.noAnim = dd.getCmd(this, NOANIM);
  718.     this.notDroppable = dd.getCmd(this, NOTDROPPABLE);
  719.     this.transparentReceiver = dd.getCmd(this, TRANSPARENT_RECEIVER);
  720.     this.ctrlPlus = dd.getCmd(this, CTRLPLUS);
  721.  
  722.     var d_j = dd_cursors.length; while(d_j--)
  723.         if(dd.getCmd(this, dd_cursors[d_j], 1)) this.cursor = dd_cursors[d_j].substring(2);
  724.     this.clone = dd.getCmd(this, CLONE, 1);
  725.     this.detach = dd.getCmd(this, DETACH_CHILDREN);
  726.     this.scalable = dd.getCmd(this, SCALABLE, 1);
  727.     this.horizontal = dd.getCmd(this, HORIZONTAL);
  728.     this.noalt = dd.getCmd(this, NO_ALT, 1);
  729.     this.nodrag = dd.getCmd(this, NO_DRAG);
  730.     this.scroll = dd.getCmd(this, SCROLL, 1);
  731.     this.resizable = dd.getCmd(this, RESIZABLE, 1);
  732.     this.autoSize = dd.getCmd(this, AUTOSIZE, 1);
  733.     this.frozen = dd.getCmd(this, FROZEN, 1);
  734.     this.dragClass = dd.getCmd(this, DRAGCLASS, 1);
  735.     this.resizableOnly = dd.getCmd(this, RESIZABLE_ONLY, 1);
  736.     if(this.resizableOnly) this.resizable=true;
  737.     this.inertia = dd.getCmd(this, INERTIA, 1);
  738.     this.bounce = !dd.getCmd(this, NOBOUNCE, 1);
  739.     this.rot = dd.getCmd(this, ROT, 1);
  740.     this.angle=0;
  741.     this.ephemeral = dd.getCmd(this, EPHEMERAL, 1);
  742.  
  743.     this.detachFromParent = dd.getCmd(this, DETACH, 1);
  744.     this.detachOffsetX = dd.getCmdVal(this, DETACHOFFSETX, 0, 0);
  745.     this.detachOffsetY = dd.getCmdVal(this, DETACHOFFSETY, 0, 0);
  746.     this.offsetX = 0; // used when object is in a overflow:scroll node, and detachFromParent is set
  747.     this.offsetY = 0; // used when object is in a overflow:scroll node, and detachFromParent is set
  748.  
  749.     this.pickDelay = dd.getCmdVal(this, PICKDELAY, 0, 0);
  750.  
  751.     this.re_z = dd.getCmd(this, RESET_Z, 1);
  752.     this.diaphan = dd.getCmd(this, TRANSPARENT, 1);
  753.     this.vertical = dd.getCmd(this, VERTICAL);
  754.     this.maxw = dd.getCmdVal(this, MAXWIDTH, 1, 1);
  755.     this.minw = Math.abs(dd.getCmdVal(this, MINWIDTH, 1, 1));
  756.     this.maxh = dd.getCmdVal(this, MAXHEIGHT, 1, 1);
  757.     this.minh = Math.abs(dd.getCmdVal(this, MINHEIGHT, 1, 1));
  758.     this.pickFunc = this.dragFunc = this.resizeFunc = this.dropFunc = this.dropFuncInertia = null;this.scrollContainer=null;
  759.  
  760.     if(this.id.indexOf('DRAGFUNC(')>=0){
  761.         this.dragFunc=this.id.substr(this.id.indexOf('DRAGFUNC(')+9).substr(0,this.id.indexOf(')')-1);
  762.         this.dragFunc=this.dragFunc.substr(0,this.dragFunc.indexOf(')'));
  763.         this.id=this.id.substr(0,this.id.indexOf('DRAGFUNC('))+this.id.substr(this.id.indexOf('DRAGFUNC(')+this.dragFunc.length+11)
  764.     }
  765.  
  766.     if(dd.getCmd(this, ISWINDOW)){
  767.         this.isWindow = 1;
  768.         this.minw = winMinW; this.minh = winMinH;
  769.         this.winState='normal';
  770.         this.resizeDir='';
  771.         this.resizeIfPick=false;
  772.     }
  773.     else this.isWindow = false;
  774.  
  775.     if(dd.getCmd(this, ISICON)) this.isIcon = true; else this.isIcon = false;
  776.     if(dd.getCmd(this, IMGFADEIN)) this.imgFadeIn = true;
  777.  
  778.     this.name = this.id + (d_i || '');
  779.     this.oimg = dd.getImg(this, this.id, 1);
  780.     this.is_image = !!this.oimg;
  781.  
  782.     this.copies = new Array();
  783.     this.children = new Array();
  784.     this.parent = this.original = null;
  785.     if(this.oimg)
  786.     {
  787.         this.id = this.name + "dIi15v";
  788.         this.w = dd.getImgW(this.oimg);
  789.         this.h = dd.getImgH(this.oimg);
  790.         this.dw = this.dh = 0;
  791.         this.defz = dd.Int(dd.getCssProp(this.oimg, 'z-index','zIndex','zIndex')) || 1;
  792.         this.defsrc = this.src = this.oimg.src;
  793.         this.htm = '<img name="' + this.id + 'NI1m6G"'+
  794.             ' src="' + this.oimg.src + '" '+ 'width="' + this.w + '" height="' + this.h + '"'
  795.         if(this.imgFadeIn) {
  796.             this.htm+='style="visibility:hidden" onload="fade(this)"';
  797.         }
  798.         this.htm+='>';
  799.         this.t_htm = '<div id="' + this.id +
  800.             '" style="position:absolute;'+
  801.             'left:' + (this.cssx = this.x = this.defx) + 'px;'+
  802.             'top:' + (this.cssy = this.y = this.defy) + 'px;'+
  803.             'width:' + this.w + 'px;'+
  804.             'height:' + this.h + 'px;">'+
  805.             this.htm + '</div>';
  806.     }
  807.     else
  808.     {
  809.         if(!!(this.div = dd.getDiv(this.id)) && typeof this.div.style != dd_u) this.css = this.div.style;
  810.         if(this.div && this.div.id && this.div.id=='mDlList') this.css = '';
  811.         dd.getWH(this);
  812.         if(this.div)
  813.         {
  814.             this.div.ddObj = this;
  815.             this.div.pos_rel = ("" + (this.div.parentNode? this.div.parentNode.tagName : this.div.parentElement? this.div.parentElement.tagName : '').toLowerCase().indexOf('body') < 0);
  816.         }
  817.         dd.getPageXY(this.div);
  818.         this.defx = this.x = dd.x;
  819.         this.defy = this.y = dd.y;
  820.         dd.getCssXY(this);
  821.         this.defz = dd.Int(dd.getCssProp(this.div, 'z-index','zIndex','zIndex'));
  822.     }
  823.     this.defw = this.w || 0;
  824.     this.defh = this.h || 0;
  825. }
  826. DDObj.prototype.setPickFunc = function (d_x){this.pickFunc = d_x;};
  827. DDObj.prototype.setDragFunc = function (d_x){this.dragFunc = d_x;};
  828. DDObj.prototype.setResizeFunc = function (d_x){this.resizeFunc = d_x;};
  829. DDObj.prototype.setDropFunc = function (d_x){this.dropFunc = d_x;};
  830. DDObj.prototype.setDropFuncInertia = function (d_x){this.dropFuncInertia = d_x;};
  831. // Called when done with dragged object
  832. DDObj.prototype.setReleasedFunc = function (d_x){this.releasedFunc = d_x;};
  833. DDObj.prototype.setScrollContainer = function (d_x){this.scrollContainer = d_x;};
  834. DDObj.prototype.moveBy = function (d_x, d_y, d_kds, d_o){
  835.     if(!this.div) return;
  836.     this.x += (d_x = dd.Int(d_x));
  837.     this.y += (d_y = dd.Int(d_y));
  838.     if(!d_kds || this.is_image || this.parent != this.defparent)
  839.     {
  840.         (d_o = this.css || this.div).left = (this.cssx += d_x) + dd.px;
  841.         d_o.top = (this.cssy += d_y) + dd.px;
  842.     }
  843.     var d_i = this.children.length; while(d_i--)
  844.     {
  845.         if(!(d_o = this.children[d_i]).detached) d_o.moveBy(d_x, d_y, 1);
  846.         d_o.defx += d_x;
  847.         d_o.defy += d_y;
  848.     }
  849. };
  850.  
  851. DDObj.prototype.moveTo = function (d_x, d_y)
  852. {
  853.     this.moveBy(((d_x===false)?0:dd.Int(d_x)-this.x), ((d_y===false)?0:dd.Int(d_y)-this.y));
  854. };
  855.  
  856. // Rotate object to d_r degrees
  857. DDObj.prototype.rotTo = function (a)
  858. {
  859.     var s=this.div.style;
  860.     s.WebkitTransform=s.MozTransform=s.OTransform='rotate('+(-a)+'deg)';
  861.     this.angle=a;
  862. };
  863.  
  864. // Rotate object by d_r degrees
  865. DDObj.prototype.rotBy = function (da){this.rotTo(this.angle+da)};
  866.  
  867.  
  868. // Launch item in given direction (common values: 0.5 < |vx/vy| < 2)
  869. DDObj.prototype.launch=function (vx,vy){
  870.     if(dd.obj==this && this.isLaunched){
  871.         dd.obj.lpdx+=vx+((dd.obj.lpdx*vx>0)?vx:0)
  872.         dd.obj.lpdy+=vy+((dd.obj.lpdy*vy>0)?vy:0)
  873.     }
  874.     else{
  875.         dd.obj=this;
  876.         dd.obj.pickDate=dd.obj.lpDate=(new Date()).getTime();
  877.         dd.obj.pickX=dd.obj.lpx=dd.obj.x;dd.obj.pickY=dd.obj.lpy=dd.obj.y;dd.obj.lpdx=vx;dd.obj.lpdy=vy;dd.obj.lpdt=1;
  878.         my_DragFunc(dd.obj.index);
  879.     }
  880. }
  881.  
  882. DDObj.prototype.hide = function (d_m, d_o, d_p)
  883. {
  884.     if(this.div && this.visible)
  885.     {
  886.         d_p = this.css || this.div;
  887.         if(d_m && !dd.n4)
  888.         {
  889.             this.display = dd.getCssProp(this.div, "display", "display", "display");
  890.             if(this.oimg)
  891.             {
  892.                 this.oimg.display = dd.getCssProp(this.oimg, "display", "display", "display");
  893.                 this.oimg.style.display = "none";
  894.             }
  895.             d_p.display = "none";
  896.             dd.recalc();
  897.         }
  898.         else d_p.visibility = "hidden";
  899.     }
  900.     this.visible = false;
  901.     var d_i = this.children.length; while(d_i--)
  902.         if(!(d_o = this.children[d_i]).detached) d_o.hide(d_m);
  903. };
  904. DDObj.prototype.show = function (d_o, d_p)
  905. {
  906.     if(this.div)
  907.     {
  908.         d_p = this.css || this.div;
  909.         if(d_p.display && d_p.display == "none")
  910.         {
  911.             d_p.display = this.display || "block";
  912.             if(this.oimg) this.oimg.style.display = this.oimg.display || "inline";
  913.             dd.recalc();
  914.         }
  915.         else d_p.visibility = "visible";
  916.     }
  917.     this.visible = true;
  918.     var d_i = this.children.length; while(d_i--)
  919.         if(!(d_o = this.children[d_i]).detached) d_o.show();
  920. };
  921. DDObj.prototype.resizeTo = function (d_w, d_h, d_o)
  922. {
  923.     if(!this.div) return;
  924.     if(d_w===false) d_w=this.w;
  925.     if(d_h===false) d_h=this.h;
  926.     if(isNaN(d_w) && (d_w=='auto' || d_w.substr(d_w.length-1,1)=='%' || d_w.substr(d_w.length-2,2)=='em')) wPx=false;
  927.     else {d_w = (this.w = dd.Int(d_w))-this.dw;    wPx=true;}
  928.     if(isNaN(d_h) && (d_h=='auto' || d_h.substr(d_h.length-1,1)=='%' || d_h.substr(d_h.length-2,2)=='em')) hPx=false;
  929.     else {d_h = (this.h = dd.Int(d_h))-this.dh;    hPx=true;}
  930.     if(dd.n4)
  931.     {
  932.         this.div.resizeTo(d_w, d_h);
  933.         if(this.is_image)
  934.         {
  935.             this.write('<img src="' + this.src + '" width="' + d_w + '" height="' + d_h + '">');
  936.             (this.nimg = this.div.D.images[0]).src = this.src;
  937.         }
  938.     }
  939.     //else if(typeof this.css.pixelWidth != dd_u) // modified on 2007/07/13
  940.     else if(wPx && hPx && typeof this.css.pixelWidth != dd_u)
  941.     {
  942.         this.css.pixelWidth = d_w;
  943.         this.css.pixelHeight = d_h;
  944.         if(this.is_image)
  945.         {
  946.             (d_o = this.nimg.style).pixelWidth = d_w;
  947.             d_o.pixelHeight = d_h;
  948.         }
  949.     }
  950.     else
  951.     {
  952.         this.css.width  = d_w + ((wPx)?dd.px:'');
  953.         this.css.height = d_h + ((hPx)?dd.px:'');
  954.         if(this.is_image)
  955.         {
  956.             (d_o = this.nimg).width = d_w;
  957.             d_o.height = d_h;
  958.             if(!d_o.complete) d_o.src = this.src;
  959.         }
  960.     }
  961. };
  962. DDObj.prototype.resizeBy = function (d_dw, d_dh)
  963. {
  964.     var rw=((d_dw=='auto')?'auto':this.w+dd.Int(d_dw));
  965.     var rh=((d_dh=='auto')?'auto':this.h+dd.Int(d_dh));
  966.     this.resizeTo(rw, rh);
  967. };
  968. DDObj.prototype.setMinHeight= function (d_dh) {this.minh=d_dh;if(this.h<d_dh) this.resizeTo('auto',d_dh);};
  969. DDObj.prototype.setMaxHeight= function (d_dh) {this.maxh=d_dh;if(this.h>d_dh) this.resizeTo('auto',d_dh);};
  970. DDObj.prototype.setMinWidth= function (d_dw) {this.minw=d_dw;if(this.w<d_dw) this.resizeTo(d_dw,'auto');};
  971. DDObj.prototype.setMaxWidth= function (d_dw) {this.maxw=d_dw;if(this.w>d_dw) this.resizeTo(d_dw,'auto');};
  972. DDObj.prototype.setInertia= function (d_dw) {this.inertia=d_dw;};
  973. DDObj.prototype.freeze= function () {this.frozen=true;};
  974. DDObj.prototype.warm= function () {this.frozen=false;};
  975.  
  976. DDObj.prototype.swapImage = function (d_x, d_cp)
  977. {
  978.     if(!this.nimg) return;
  979.     this.nimg.src = d_x;
  980.     this.src = this.nimg.src;
  981.     if(d_cp)
  982.     {
  983.         var d_i = this.copies.length; while(d_i--)
  984.             this.copies[d_i].src = this.copies[d_i].nimg.src = this.nimg.src;
  985.     }
  986. };
  987. DDObj.prototype.setBgColor = function (d_x)
  988. {
  989.     if(dd.n4 && this.div) this.div.bgColor = d_x;
  990.     else if(this.css) this.css.background = d_x;
  991.     this.bgColor = d_x;
  992. };
  993. DDObj.prototype.write = function (d_x, d_o)
  994. {
  995.     this.text = d_x;
  996.     if(!this.div) return;
  997.     if(dd.n4)
  998.     {
  999.         (d_o = this.div.document).open();
  1000.         d_o.write(d_x);
  1001.         d_o.close();
  1002.         dd.getWH(this);
  1003.     }
  1004.     else
  1005.     {
  1006.         this.css.height = 'auto';
  1007.         this.div.innerHTML = d_x;
  1008.         if(!dd.ie4) dd.recalc();
  1009.         if(dd.ie4 || dd.n6) setTimeout('dd.recalc();', 0); // n6.0: recalc twice
  1010.     }
  1011. };
  1012. DDObj.prototype.copy = function (d_n, d_p, d_b)
  1013. {
  1014.     if(!this.oimg) return;
  1015.     d_b = (dd.ie && D.all.tags('body'))? D.all.tags('body')[0] : D.getElementsByTagName? (D.getElementsByTagName('body')[0] || dd.db) : dd.db;
  1016.     d_n = d_n || 1;
  1017.     while(d_n--)
  1018.     {
  1019.         var d_l = this.copies.length,
  1020.         d_o = new DDObj(this.name+this.cmd, d_l+1);
  1021.         if(dd.n4)
  1022.         {
  1023.             d_o.id = (d_p = new Layer(d_o.w)).name;
  1024.             d_p.clip.height = d_o.h;
  1025.             d_p.visibility = 'show';
  1026.             (d_p = d_p.document).open();
  1027.             d_p.write(d_o.htm);
  1028.             d_p.close();
  1029.         }
  1030.         else if(d_b && d_b.insertAdjacentHTML) d_b.insertAdjacentHTML("AfterBegin", d_o.t_htm);
  1031.         else if(D.createElement && d_b && d_b.appendChild)
  1032.         {
  1033.             d_b.appendChild(d_p = D.createElement("dIi15v"));
  1034.             d_p.innerHTML = d_o.htm;
  1035.             d_p.id = d_o.id;
  1036.             d_p.style.position = 'absolute';
  1037.             d_p.style.width = d_o.w + 'px';
  1038.             d_p.style.height = d_o.h + 'px';
  1039.         }
  1040.         else if(d_b && d_b.innerHTML) d_b.innerHTML += d_o.t_htm;
  1041.         d_o.defz = this.defz+1+d_l;
  1042.         dd.addProps(d_o);
  1043.         d_o.original = this;
  1044.         dd.addElt(d_o, this);
  1045.         if(this.parent)
  1046.         {
  1047.             this.parent.addChild(d_o, this.detached);
  1048.             d_o.defparent = this.defparent;
  1049.         }
  1050.         d_o.moveTo(d_o.defx = this.defx, d_o.defy = this.defy);
  1051.         if(dd.n4) d_o.defsrc = d_o.src = this.defsrc;
  1052.         d_o.swapImage(this.src);
  1053.     }
  1054. };
  1055. DDObj.prototype.addChild = function (d_kd, detach, defp)
  1056. {
  1057.     if(typeof d_kd != "object") d_kd = dd.elements[d_kd];
  1058.     if(d_kd.parent && d_kd.parent == this || d_kd == this || !d_kd.is_image && d_kd.defparent && !defp) return;
  1059.  
  1060.     this.children[this.children.length] = this.children[d_kd.name] = d_kd;
  1061.     d_kd.detached = detach || 0;
  1062.     if(defp) d_kd.defparent = this;
  1063.     else if(this == d_kd.defparent && d_kd.is_image) dd.getImg(this, d_kd.oimg.name, 1);
  1064.     if(!d_kd.defparent || this != d_kd.defparent)
  1065.     {
  1066.         d_kd.defx = d_kd.x;
  1067.         d_kd.defy = d_kd.y;
  1068.     }
  1069.     if(!detach)
  1070.     {
  1071.         d_kd.defz = d_kd.defz+this.defz-(d_kd.parent? d_kd.parent.defz : 0)+(!d_kd.is_image*1);
  1072.         d_kd.setZ(d_kd.z+this.z-(d_kd.parent? d_kd.parent.z : 0)+(!d_kd.is_image*1), 1);
  1073.     }
  1074.     if(d_kd.parent) d_kd.parent._removeChild(d_kd, 1);
  1075.     d_kd.parent = this;
  1076. };
  1077. DDObj.prototype._removeChild = function (d_kd, d_newp)
  1078. {
  1079.     if(typeof d_kd != "object") d_kd = this.children[d_kd];
  1080.     var d_oc = this.children, d_nc = new Array();
  1081.     for(var d_i = 0; d_i < d_oc.length; d_i++)
  1082.         if(d_oc[d_i] != d_kd) d_nc[d_nc.length] = d_oc[d_i];
  1083.     this.children = d_nc;
  1084.     d_kd.parent = null;
  1085.     if(!d_newp)
  1086.     {
  1087.         d_kd.detached = d_kd.defp = 0;
  1088.         if(d_kd.is_image) dd.getImg(d_kd, d_kd.oimg.name, 1);
  1089.     }
  1090. };
  1091. DDObj.prototype.attachChild = function (d_kd)
  1092. {
  1093.     (d_kd = (typeof d_kd != "object")? this.children[d_kd]: d_kd).detached = 0;
  1094.     d_kd.setZ(d_kd.defz + this.z-this.defz, 1);
  1095. };
  1096. DDObj.prototype.detachChild = function (d_kd)
  1097. {
  1098.     (d_kd = (typeof d_kd != "object")? this.children[d_kd]: d_kd).detached = 1;
  1099. };
  1100. DDObj.prototype.setZ = function (d_x, d_kds, d_o)
  1101. {
  1102.     if(d_kds)
  1103.     {
  1104.         var d_dz = d_x-this.z,
  1105.         d_i = this.children.length; while(d_i--)
  1106.             if(!(d_o = this.children[d_i]).detached) d_o.setZ(d_o.z+d_dz, 1);
  1107.     }
  1108.     dd.z = Math.max(dd.z, this.z = this.div? ((this.css || this.div).zIndex = d_x) : 0);
  1109.     if(this.z>0) dd.zMin = Math.max(0,Math.min(dd.zMin, this.z));
  1110. };
  1111. DDObj.prototype.maximizeZ = function ()
  1112. {
  1113.     this.setZ(dd.z+1, 1);
  1114. };
  1115. DDObj.prototype.minimizeZ = function ()
  1116. {
  1117.     this.setZ(Math.max(0,dd.zMin-1), 1);
  1118. };
  1119. DDObj.prototype._resetZ = function (d_o)
  1120. {
  1121.     if(this.re_z || dd.re_z)
  1122.     {
  1123.         this.setZ(this.defz);
  1124.         var d_i = this.children.length; while(d_i--)
  1125.             if(!(d_o = this.children[d_i]).detached) d_o.setZ(d_o.defz);
  1126.     }
  1127. };
  1128. // Set opacity (0-1)
  1129. DDObj.prototype.setOpacity = function (d_x)
  1130. {
  1131.     this.opacity = d_x;
  1132.     this._setOpaRel(1.0, 1);
  1133. };
  1134. DDObj.prototype._setOpaRel = function (d_x, d_kd, d_y, d_o)
  1135. {
  1136.     if(this.css && (this.diaphan || d_kd))
  1137.     {
  1138.         d_y = this.opacity*d_x;
  1139.         if(typeof this.css.MozOpacity != dd_u) this.css.MozOpacity = d_y;
  1140.         else if(typeof this.css.filter != dd_u){
  1141.             if(typeof this.div.style.opacity!=dd_u) this.div.style.opacity=d_y; // Weezo mod for opera 9.5
  1142.             else this.css.filter = "Alpha(opacity="+parseInt(100*d_y)+")";
  1143.         }
  1144.         else this.css.opacity = d_y;
  1145.         var d_i = this.children.length; while(d_i--)
  1146.             if(!(d_o = this.children[d_i]).detached) d_o._setOpaRel(d_x, 1);
  1147.     }
  1148. };
  1149. DDObj.prototype.setCursor = function (d_x)
  1150. {
  1151.     this._setCrs(this.cursor = (d_x.indexOf('c:')+1)? d_x.substring(2) : d_x);
  1152. };
  1153. DDObj.prototype._setCrs = function (d_x)
  1154. {
  1155.     if(this.css) this.css.cursor = ((!dd.ie || dd.iemac) && d_x == 'hand')? 'pointer' : d_x;
  1156. };
  1157. DDObj.prototype.setDraggable = function (d_x)
  1158. {
  1159.     this.nodrag = !d_x*1;
  1160.     this._setCrs(d_x? this.cursor : 'auto');
  1161. };
  1162. DDObj.prototype.setResizable = function (d_x)
  1163. {
  1164.     this.resizable = d_x*1;
  1165.     if(d_x) this.scalable = 0;
  1166. };
  1167. DDObj.prototype.setScalable = function (d_x)
  1168. {
  1169.     this.scalable = d_x*1;
  1170.     if(d_x) this.resizable = 0;
  1171. };
  1172. DDObj.prototype.getEltBelow = function (d_ret, d_x, d_y)
  1173. {
  1174.     var d_o, d_cmp = -1, d_i = dd.elements.length; while(d_i--)
  1175.     {
  1176.         d_o = dd.elements[d_i];
  1177.         d_x = d_o.x-this.w/2-((d_o.scrollContainer)?d_o.scrollContainer.scrollLeft:0);
  1178.         d_y = d_o.y-this.h/2-((d_o.scrollContainer)?d_o.scrollContainer.scrollTop:0);
  1179.         if(d_o.visible && d_o.z < this.z && this.x >= d_x && this.x <= d_x+d_o.w && this.y >= d_y && this.y <= d_y+d_o.h)
  1180.         {
  1181.             if(d_o.z > d_cmp)
  1182.             {
  1183.                 //Remove items scrolled out of view
  1184.                 if(d_o.scrollContainer && (d_o.div.offsetTop-d_o.scrollContainer.scrollTop<0 || d_o.div.offsetTop-d_o.scrollContainer.scrollTop>d_o.scrollContainer.offsetHeight)){}
  1185.                 else{
  1186.                     d_cmp = d_o.z;
  1187.                     d_ret = d_o;
  1188.                     return d_ret;
  1189.                 }
  1190.             }
  1191.         }
  1192.     }
  1193.     //return d_ret;
  1194. };
  1195. // Time elapsed since pick (ms)
  1196. DDObj.prototype.pickTime = function (){return wl.chrono.microtime() - this.pickDate;}
  1197.  
  1198.  
  1199. // Script load monitoring
  1200. if(W.lFunc) lFunc('wz_dragdrop',25);
  1201.  
  1202. /**
  1203.  * @desc Get receiver-only object below object
  1204.  * @param boolean setRec: true to recompute objects positions, false to use stored position
  1205.  * @param boolean useMousePos: true to use mouse position instead of objects borders
  1206.  * @return DOM node (or null if not found)
  1207.  */
  1208. DDObj.prototype.receiverOnlyGetEltBelow = function (computePositions, useMousePos)
  1209. {
  1210.     if(computePositions==undefined || computePositions) drec.computeRect();
  1211.     if(useMousePos==undefined) useMousePos=1;
  1212.     var aol; var aot=0; var isP; var o; var rect;
  1213.     var found=new Array();
  1214.     var sdx; var sdy; var rectx; var recty;
  1215.  
  1216.     // Browse elements to find elements below
  1217.     for(i in drec.elements) {
  1218.  
  1219.         var ob=drec.elements[i];
  1220.         if(!ob.rect) ob.rect=actualRect(ob);
  1221.         rectx=ob.rect.x-((ob.scrollContainer)?ob.scrollContainer.scrollLeft:0);
  1222.         recty=ob.rect.y-((ob.scrollContainer)?ob.scrollContainer.scrollTop:0);
  1223.  
  1224.         if(useMousePos)
  1225.             if(rectx<=mouseX&&rectx+ob.rect.w>=mouseX&&recty<=mouseY&&recty+ob.rect.h>=mouseY) found[found.length]=ob;
  1226.         else
  1227.             if(rectx<=this.x+this.w && rectx+ob.rect.w>=this.x&&recty<=this.y+this.h&&recty+ob.rect.h>=this.y) found[found.length]=ob;
  1228.     }
  1229.     // In results, search 1st element with no child
  1230.     for(i=found.length-1;i>=0;i--){
  1231.         if(i==0) return found[0];
  1232.         else{
  1233.             for(o=i-1;o>=0;o--) {
  1234.                 if(isParent(found[i],found[o])) break;
  1235.             }
  1236.             if(o<0) return found[i];
  1237.         }
  1238.     }
  1239.     return null;
  1240. }
  1241.  
  1242. DDObj.prototype.del = function (no_recalc)
  1243. {
  1244.     var d_i;
  1245.     if(this.parent && this.parent._removeChild) this.parent._removeChild(this);
  1246.     if(this.original)
  1247.     {
  1248.         this.hide();
  1249.         if(this.original.copies)
  1250.         {
  1251.             d_os = new Array();
  1252.             for(d_i = 0; d_i < this.original.copies.length; d_i++)
  1253.                 if((d_o = this.original.copies[d_i]) != this) d_os[d_o.name] = d_os[d_os.length] = d_o;
  1254.             this.original.copies = d_os;
  1255.         }
  1256.     }
  1257.     else if(this.is_image)
  1258.     {
  1259.         this.hide();
  1260.         if(this.oimg)
  1261.         {
  1262.           if(dd.n4) this.oimg.src = this.defsrc;
  1263.           else this.oimg.style.visibility = 'visible';
  1264.         }
  1265.     }
  1266.     else if(this.moveTo)
  1267.     {
  1268.         if(this.css) this.css.cursor = 'default';
  1269.         this.moveTo(this.defx, this.defy);
  1270.         this.resizeTo(this.defw, this.defh);
  1271.     }
  1272.     d_os = new Array();
  1273.     for(d_i = 0; d_i < dd.elements.length; d_i++)
  1274.     {
  1275.         if((d_o = dd.elements[d_i]) != this) d_os[d_o.name] = d_os[d_o.index = d_os.length] = d_o;
  1276.         else d_o._free();
  1277.     }
  1278.     dd.elements = d_os;
  1279.     if(!dd.n4 && (no_recalc==undefined || no_recalc===false)) dd.recalc();
  1280. };
  1281. DDObj.prototype.released = function (){
  1282.     if(this.releasedFunc) this.releasedFunc(this);
  1283.     if(this.ephemeral) this.del(1);
  1284. }
  1285.  
  1286. DDObj.prototype._free = function ()
  1287. {
  1288.     for(var d_i in this)
  1289.         this[d_i] = null;
  1290.     dd.elements[this.name] = null;
  1291. };
  1292. dd.n4RectVis = function (vis)
  1293. {
  1294.     for(var d_i = 4; d_i--;)
  1295.     {
  1296.         dd.rectI[d_i].visibility = dd.rectA[d_i].visibility = vis? 'show' : 'hide';
  1297.         if(vis) dd.rectI[d_i].zIndex = dd.rectA[d_i].zIndex = dd.z+2;
  1298.     }
  1299. };
  1300. dd.n4RectPos = function (d_o, d_x, d_y, d_w, d_h)
  1301. {
  1302.     d_o.x = d_x;
  1303.     d_o.y = d_y;
  1304.     d_o.clip.width = d_w;
  1305.     d_o.clip.height = d_h;
  1306. };
  1307. // NN4: Draw img sizing rect
  1308. dd.n4Rect = function (d_w, d_h)
  1309. {
  1310.     var d_i;
  1311.     if(!dd.rectI)
  1312.     {
  1313.         dd.rectI = new Array();
  1314.         dd.rectA = new Array();
  1315.     }
  1316.     if(!dd.rectI[0])
  1317.     {
  1318.         for(d_i = 4; d_i--;)
  1319.         {
  1320.             (dd.rectI[d_i] = new Layer(1)).bgColor = '#000000';
  1321.             (dd.rectA[d_i] = new Layer(1)).bgColor = '#ffffff';
  1322.         }
  1323.     }
  1324.     if(!dd.rectI[0].visibility || dd.rectI[0].visibility == 'hide') dd.n4RectVis(1);
  1325.     dd.obj.w = d_w;
  1326.     dd.obj.h = d_h;
  1327.     for(d_i = 4; d_i--;)
  1328.     {
  1329.         dd.n4RectPos(dd.rectI[d_i], dd.obj.x + (!(d_i-1)? (dd.obj.w-1) : 0), dd.obj.y + (!(d_i-2)? (dd.obj.h-1) : 0), d_i&1 || dd.obj.w, !(d_i&1) || dd.obj.h);
  1330.         dd.n4RectPos(dd.rectA[d_i], !(d_i-1)? dd.rectI[1].x+1 : (dd.obj.x-1), !(d_i-2)? dd.rectI[2].y+1 : (dd.obj.y-1), d_i&1 || dd.obj.w+2, !(d_i&1) || dd.obj.h+2);
  1331.     }
  1332. };
  1333. dd.reszTo = function (d_w, d_h)
  1334. {
  1335.     if(dd.n4 && dd.obj.is_image) dd.n4Rect(d_w, d_h);
  1336.     else dd.obj.resizeTo(d_w, d_h);
  1337. };
  1338. dd.embedVis = function (d_vis)
  1339. {
  1340.     var d_o = new Array('iframe', 'applet', 'embed', 'object');
  1341.     var d_i = d_o.length; while(d_i--)
  1342.     {
  1343.         var d_p = dd.ie? D.all.tags(d_o[d_i]) : D.getElementsByTagName? D.getElementsByTagName(d_o[d_i]) : null;
  1344.         if(d_p)
  1345.         {
  1346.             var d_j = d_p.length; while(d_j--)
  1347.             {
  1348.                 var d_q = d_p[d_j];
  1349.                 while(d_q.offsetParent || d_q.parentNode)
  1350.                 {
  1351.                     if((d_q = d_q.parentNode || d_q.offsetParent || null) == dd.obj.div)
  1352.                     {
  1353.                         d_p[d_j].style.visibility = d_vis;
  1354.                         break;
  1355.                     }
  1356.                 }
  1357.             }
  1358.         }
  1359.     }
  1360. };
  1361.  
  1362. dd.maxOffX = function (d_x, d_y)
  1363. {
  1364.     return(
  1365.         (dd.obj.maxoffl+1 && (d_y = dd.obj.defx-dd.obj.maxoffl)-d_x > 0
  1366.         || dd.obj.maxoffr+1 && (d_y = dd.obj.defx+dd.obj.maxoffr)-d_x < 0)? d_y
  1367.         : d_x
  1368.     );
  1369. };
  1370. dd.maxOffY = function (d_x, d_y)
  1371. {
  1372.     return(
  1373.         (dd.obj.maxofft+1 && (d_y = dd.obj.defy-dd.obj.maxofft)-d_x > 0
  1374.         || dd.obj.maxoffb+1 && (d_y = dd.obj.defy+dd.obj.maxoffb)-d_x < 0)? d_y
  1375.         : d_x
  1376.     );
  1377. };
  1378. dd.inWndW = function (d_x, d_y)
  1379. {
  1380.     var d_wx = dd.getScrollX(),
  1381.     d_ww = dd.getWndW();
  1382.     return(
  1383.         ((d_y = d_wx+2)-d_x > 0) || ((d_y = d_wx+d_ww+dd.obj.w-2)-d_x < 0)? d_y
  1384.         : d_x
  1385.     );
  1386. };
  1387. dd.inWndH = function (d_x, d_y)
  1388. {
  1389.     var d_wy = dd.getScrollY(),
  1390.     d_wh = dd.getWndH();
  1391.     return(
  1392.         ((d_y = d_wy+2)-d_x > 0) || ((d_y = d_wy+d_wh+dd.obj.h-2)-d_x < 0)? d_y
  1393.         : d_x
  1394.     );
  1395. };
  1396. // These two funcs limit the size of element when mouseresized.
  1397. // Implemented 22.5.2003 by Gregor Ltolf <gregor@milou.ch>, modified by Walter Zorn
  1398. dd.limW = function (d_w)
  1399. {
  1400.     return(
  1401.         (dd.obj.minw-d_w > 0)? dd.obj.minw
  1402.         : (dd.obj.maxw > 0 && dd.obj.maxw-d_w < 0)? dd.obj.maxw
  1403.         : d_w
  1404.     );
  1405. };
  1406. dd.limH = function (d_h)
  1407. {
  1408.     return(
  1409.         (dd.obj.minh-d_h > 0)? dd.obj.minh
  1410.         : (dd.obj.maxh > 0 && dd.obj.maxh-d_h < 0)? dd.obj.maxh
  1411.         : d_h
  1412.     );
  1413. };
  1414.  
  1415. /**
  1416.  * Return vector (d:distance, a:angle, in degrees) from object center to mouse position
  1417.  */
  1418. dd.rotVect = function (o){
  1419.     var r={},cx=o.x+o.w/2,cy=o.y+o.h/2,dx=mouseX-cx,dy=mouseY-cy;
  1420.     r['d']=Math.sqrt(dx*dx+dy*dy);
  1421.     if(dx==0) {r['a']=90; if(dy>0) r['a']=-90;}
  1422.     else{
  1423.         r['a']=180*Math.atan(-dy/dx)/Math.PI;
  1424.         if(dx<0) r['a']+=180;
  1425.         if(r['a']>180) r['a']-=360;
  1426.     }
  1427.     return r;
  1428. }
  1429.  
  1430.  
  1431. // Optional autoscroll-page functionality. Courtesy Cedric Savarese.
  1432. // Implemented by Walter Zorn
  1433. function DDScroll()
  1434. {
  1435.     if(!dd.obj || !dd.obj.scroll && !dd.scroll || dd.ie4 || dd.whratio)
  1436.     {
  1437.         dd.scrx = dd.scry = 0;
  1438.         return;
  1439.     }
  1440.     var d_bnd = 0x1c,
  1441.     d_wx = dd.getScrollX(), d_wy = dd.getScrollY();
  1442.     if(dd.msmoved)
  1443.     {
  1444.         var d_ww = dd.getWndW(), d_wh = dd.getWndH(), d_y;
  1445.         dd.scrx = ((d_y = dd.e.x-d_ww-d_wx+d_bnd) > 0)? (d_y>>=2)*d_y
  1446.             : ((d_y = d_wx+d_bnd-dd.e.x) > 0)? -(d_y>>=2)*d_y
  1447.             : 0;
  1448.         dd.scry = ((d_y = dd.e.y-d_wh-d_wy+d_bnd) > 0)? (d_y>>=2)*d_y
  1449.             : ((d_y = d_wy+d_bnd-dd.e.y) > 0)? -(d_y>>=2)*d_y
  1450.             : 0;
  1451.     }
  1452.     if(dd.scrx || dd.scry)
  1453.     {
  1454.         W.scrollTo(
  1455.             d_wx + (dd.scrx = dd.obj.is_resized? dd.limW(dd.obj.w+dd.scrx)-dd.obj.w : dd.obj.vertical? 0 : (dd.maxOffX(dd.obj.x+dd.scrx)-dd.obj.x)),
  1456.             d_wy + (dd.scry = dd.obj.is_resized? dd.limH(dd.obj.h+dd.scry)-dd.obj.h : dd.obj.horizontal? 0 : (dd.maxOffY(dd.obj.y+dd.scry)-dd.obj.y))
  1457.         );
  1458.         dd.obj.is_dragged? dd.obj.moveTo(dd.obj.x+dd.getScrollX()-d_wx, dd.obj.y+dd.getScrollY()-d_wy)
  1459.             : dd.reszTo(dd.obj.w+dd.getScrollX()-d_wx, dd.obj.h+dd.getScrollY()-d_wy);
  1460.     }
  1461.     dd.msmoved = 0;
  1462.     W.setTimeout('DDScroll()', 0x33);
  1463. }
  1464. function PICK_CANCEL(d_ev){
  1465.     W.clearTimeout(dd.delayedPickTimeout);
  1466.     dd.delayedPickTimeout=0;
  1467.     dd.setUpHdl(dd.upFunc);
  1468. }
  1469. function PICK(d_ev)
  1470. {
  1471.     var par,offsetX,offsetY,delayedPick=0,o,n;
  1472.     if(dd.disabled) return true;
  1473.  
  1474.     // Resume delayed pick
  1475.     if(d_ev=='resume'){
  1476.         if(!dd.delayedPickTimeout) return;
  1477.         W.clearTimeout(dd.delayedPickTimeout);
  1478.         dd.delayedPickTimeout=0;
  1479.         dd.e=dd.delayedPickEvt;
  1480.         delayedPick=1;
  1481.     }
  1482.     else {
  1483.         updateMousePosition(d_ev);
  1484.         dd.e = new dd.evt(d_ev);
  1485.     }
  1486.  
  1487.     // Right-click: cancel (except for Opera, redirect to onrightclick function that has not been called by the oncontextmenu function)
  1488.     /*
  1489.     if(dd.e.button>1){
  1490.         if(dd.op && W.onrightclick) return onrightclick(d_ev);
  1491.         return false;
  1492.     }
  1493.     */
  1494.  
  1495.     if(dd.e.x >= dd.getWndW()+dd.getScrollX() || dd.e.y >= dd.getWndH()+dd.getScrollY()) return true; // on scrollbar
  1496.  
  1497.     var srcO,d_o, d_t, d_cmp = -1, d_i = dd.elements.length;
  1498.  
  1499.     // Try to find target with src property
  1500.     if(n=dd.e.src) while(1){
  1501.         if(n.id && (srcO=dd.elements[n.id])){
  1502.             break;
  1503.         }
  1504.         if(!n.parentNode||n.parentNode===n) break;
  1505.         n=n.parentNode;
  1506.     }
  1507.  
  1508.     while(d_i--){
  1509.         d_o = dd.elements[d_i];
  1510.         if(srcO && d_o!==srcO) continue;
  1511.         offsetX=offsetY=0;
  1512.  
  1513.         // Netscape : inlude parent's node scroll offset
  1514.         if(d_o.detachFromParent && (!dd.op)){
  1515.             par=d_o.div.parentNode;
  1516.  
  1517.             while(par && (!par.style || !par.style.overflow || par.style.overflow=='visible')) {
  1518.                 if(par==par.parentNode) break;
  1519.                 par=par.parentNode;
  1520.             }
  1521.             if(par){
  1522.                 offsetY=par.scrollTop;
  1523.                 offsetX=par.scrollLeft;
  1524.             }
  1525.         }
  1526.         if(dd.n4 && dd.e.but > 1 && dd.e.src == d_o.oimg && !d_o.clone) return false;
  1527.         if(srcO || (d_o.visible && dd.e.but <= 1 && dd.e.x >= d_o.x - offsetX && dd.e.x <= d_o.x+d_o.w-offsetX && dd.e.y >= d_o.y - offsetY && dd.e.y <= d_o.y+d_o.h - offsetY)) {
  1528.             if(d_o.z > d_cmp && (d_t = dd.e.src.tag).indexOf('inpu') < 0 && d_t.indexOf('texta') < 0 && d_t.indexOf('sele') < 0 && d_t.indexOf('opti') < 0 && d_t.indexOf('scrol') < 0 && (!dgi('maskDiv') || dgi('maskDiv').style.zIndex*1<d_o.z))
  1529.             {
  1530.                 d_cmp = d_o.z;
  1531.                 if(!d_o.frozen)    {
  1532.                     o=dd.obj = d_o;
  1533.                     o.offsetX=offsetX;o.offsetY=offsetY;
  1534.                 }
  1535.             }
  1536.         }
  1537.     }
  1538.  
  1539.     if(o){
  1540.         // Start delayed pick
  1541.         if(o.pickDelay && !delayedPick){
  1542.             dd.delayedPickEvt = new dd.evt(d_ev);
  1543.             dd.setUpHdl(PICK_CANCEL);
  1544.             dd.delayedPickTimeout=W.setTimeout('PICK("resume")',o.pickDelay);
  1545.             o=dd.obj=null;
  1546.             return false;
  1547.         }
  1548.         if(o.isWindow) win(o.name).select();
  1549.  
  1550.         // Add "dragged" to class
  1551.         if(o.dragClass) $(o.div).e.className().add('dragged');
  1552.  
  1553.         if(o.nodrag) o=dd.obj = null;
  1554.         else {
  1555.             // Store mouse coordinates
  1556.             o.mPickX=mouseX; o.mPickY=mouseY;
  1557.  
  1558.             if(o.rot){
  1559.                 // store object center coordinates
  1560.                 o.cPickX=o.x+o.w/2; o.cPickY=o.y+o.h/2;
  1561.  
  1562.                 // store object source width & height
  1563.                 o.pickW=o.w; o.pickH=o.h;
  1564.  
  1565.                 // store object actual css rotation
  1566.                 var s=o.div.style,r=(s.MozTransform||s.WebkitTransform||s.OTransform)
  1567.                 o.lpa=o.angle=o.pickAngle=(r&&r.indexOf)?-1*(r.substring(r.indexOf('(')+1,r.indexOf('d'))):0;
  1568.  
  1569.                 // Store center-mouse vector angle and length
  1570.                 o.pickRotVect=dd.rotVect(o);
  1571.             }
  1572.  
  1573.  
  1574.             var d_rsz = (dd.e.modifKey || dd.e.ctrlKey) && (o.resizable || o.scalable);
  1575.             if(dd.op)
  1576.             {
  1577.                 (d_o = dgi('OpBlUr')).style.pixelLeft = dd.e.x;
  1578.                 d_o.style.pixelTop = dd.e.y;
  1579.                 (d_o = d_o.children[0].children[0]).focus();
  1580.                 d_o.blur();
  1581.             }
  1582.             else if(dd.ie && !dd.ie4)
  1583.             {
  1584.                 if(D.selection && D.selection.empty) D.selection.empty();
  1585.                 dd.db.onselectstart = function ()
  1586.                 {
  1587.                     event.returnValue = false;
  1588.                 };
  1589.             }
  1590.             if(d_rsz || o.resizeIfPick || o.resizableOnly)
  1591.             {
  1592.  
  1593.                 if(!o.isWindow) {
  1594.                     if(o.minh==o.maxh) o._setCrs('e-resize');
  1595.                     else {
  1596.                         if(o.minw==o.maxw) o._setCrs('s-resize'); else o._setCrs('se-resize');
  1597.                     }
  1598.                 }
  1599.                 if(o.isWindow) {
  1600.                     if(dd.op) win(o.name).resizeMask();
  1601.                     //if(dd.op) dgi(o.name+"_mask").style.height=dgi(o.name+"_if").style.height;
  1602.                     dgi(o.name+"_mask").style.display="block";
  1603.                 }
  1604.                 o.is_resized = 1;
  1605.                 dd.whratio = o.scalable? o.defw/o.defh : 0;
  1606.                 if(dd.ie)
  1607.                 {
  1608.                     if(dd.ie4)
  1609.                     {
  1610.                         W.dd_x = dd.getScrollX();
  1611.                         W.dd_y = dd.getScrollY();
  1612.                     }
  1613.                     
  1614.                     setTimeout(
  1615.                         'if(dd.obj && D.selection && D.selection.empty)'+
  1616.                         '{D.selection.empty();if(dd.ie4) W.scrollTo(W.dd_x, W.dd_y);}',0);
  1617.                 }
  1618.                 dd.setMovHdl(RESIZE);
  1619.                 dd.reszTo(o.w, o.h);
  1620.             }
  1621.             else
  1622.             {
  1623.  
  1624.                 o.is_dragged = 1;
  1625.                 if(o.isWindow) {
  1626.                     //if(dd.op) dgi(o.name+"_mask").style.width=dgi(o.name+"_if").style.width;
  1627.                     if(dd.op) dgi(o.name+"_mask").style.height=dgi(o.name+"_if").offsetHeight + " ";
  1628.                     dgi(o.name+"_mask").style.display="block";
  1629.                 }
  1630.                 dd.setMovHdl(DRAG);
  1631.             }
  1632.             
  1633.             dd.setUpHdl(DROP);
  1634.             if(!o.isWindow) dd.embedVis('hidden');
  1635.             o._setOpaRel(0.7);
  1636.             o.maximizeZ();
  1637.             dd.ofx = o.x+o.w-dd.e.x;
  1638.             dd.ofy = o.y+o.h-dd.e.y;
  1639.  
  1640.             o.pickMouseX=mouseX;o.pickMouseY=mouseY;
  1641.             o.pickX=o.lpx=o.x;o.pickY=o.lpy=o.y;o.lpdx=0;o.lpdy=0;o.lpdt=0;
  1642.             o.pickDate=o.lpDate=(new Date()).getTime();
  1643.  
  1644.             my_PickFunc();
  1645.             if(o.pickFunc) o.pickFunc();
  1646.             DDScroll();
  1647.  
  1648.             return !(
  1649.                 o.is_resized
  1650.                 || dd.n4 && o.is_image
  1651.                 || dd.n6 || dd.w3c
  1652.             );
  1653.         }
  1654.     }
  1655.  
  1656.     if(dd.downFunc) return dd.downFunc(d_ev);
  1657.     return true;
  1658. }
  1659.  
  1660. function DRAG(d_ev)
  1661. {
  1662.     var o=dd.obj;
  1663.     if(dd.disabled) return true;
  1664.     updateMousePosition(d_ev);
  1665.  
  1666.     if(!o || !o.visible) return true;
  1667.     o.resizeIfPick=false;
  1668.     if(dd.ie4 || dd.w3c || dd.n6 || o.children.length > 0xf)
  1669.     {
  1670.         if(dd.wait) return false;
  1671.         dd.wait = 1;
  1672.         setTimeout('dd.wait = 0;', dd.tiv);
  1673.     }
  1674.     dd.e = new dd.evt(d_ev);
  1675.  
  1676.     if(dd.ie && !dd.e.but)
  1677.     {
  1678.         DROP(d_ev);
  1679.         return true;
  1680.     }
  1681.  
  1682.     dd.msmoved = 1;
  1683.  
  1684.     // Window or icon dragged: use desktop padding for boundaries
  1685.     if(o.isWindow || o.isIcon){
  1686.         var p=dd.getPadding(),
  1687.         nx=Math.max(p.left,dd.maxOffX(dd.inWndW(dd.ofx+dd.e.x)-o.w)),
  1688.         ny=Math.max(p.top,dd.maxOffY(dd.inWndH(dd.ofy+dd.e.y)-o.h));
  1689.  
  1690.         if(W.winLimitArea!==0){
  1691.             nx=Math.min(nx,dd.getWndW()-o.w-p.right);
  1692.             ny=Math.min(ny,dd.getWndH()-o.h-p.bottom);
  1693.         }
  1694.         o.moveTo(o.vertical? o.x : nx, o.horizontal? o.y : ny);
  1695.     }
  1696.  
  1697.     // If object has rotation, use a special drag&rotate function
  1698.     else if(o.rot && o.pickRotVect['d']>o.w/4){
  1699.         var nV=dd.rotVect(o),a=Math.PI*(nV['a']+180)/180,d=o.pickRotVect['d'];
  1700.         o.moveTo(mouseX+d*Math.cos(a)-o.w/2,mouseY-d*Math.sin(a)-o.h/2)
  1701.         o.rotTo(o.pickAngle+nV['a']-o.pickRotVect['a'])
  1702.     }
  1703.     else
  1704.         if(o.detachFromParent) o.moveTo(
  1705.         - o.offsetX + (o.detachOffsetX?o.detachOffsetX:0) + (o.vertical? o.x : dd.ofx+dd.e.x-o.w),
  1706.         - o.offsetY + (o.detachOffsetY?o.detachOffsetY:0) + (o.horizontal? o.y : dd.ofy+dd.e.y-o.h));
  1707.         else o.moveTo(
  1708.         - o.offsetX + (o.detachOffsetX?o.detachOffsetX:0) + (o.vertical? o.x : dd.maxOffX(dd.inWndW(dd.ofx+dd.e.x)-o.w)),
  1709.         - o.offsetY + (o.detachOffsetY?o.detachOffsetY:0) + (o.horizontal? o.y : dd.maxOffY(dd.inWndH(dd.ofy+dd.e.y)-o.h))        );
  1710.     if(o.maxXPos && o.x>o.maxXPos) o.moveTo(o.maxXPos,false);
  1711.     if(o.minXPos && o.x<o.minXPos) o.moveTo(o.minXPos,false);
  1712.     if(o.mayYPos && o.y>o.mayYPos) o.moveTo(o.mayYPos,false);
  1713.     if(o.minYPos && o.y<o.minYPos) o.moveTo(o.minYPos,false);
  1714.     my_DragFunc();
  1715.  
  1716.     if(o.dragFunc) {
  1717.         if(typeof o.dragFunc=='string') eval (o.dragFunc+'()'); else o.dragFunc();
  1718.     }
  1719.     return MOUSE_MOVED(d_ev);
  1720. }
  1721.  
  1722. function RESIZE(d_ev)
  1723. {
  1724.     var o=dd.obj;
  1725.     updateMousePosition(d_ev);
  1726.     if(!o || !o.visible) return true;
  1727.     if(dd.wait) return false;
  1728.     dd.wait = 1;
  1729.     setTimeout('dd.wait = 0;', dd.tiv);
  1730.     dd.e = new dd.evt(d_ev);
  1731.  
  1732.     if(dd.ie && !dd.e.but)
  1733.     {
  1734.         DROP(d_ev);
  1735.         return true;
  1736.     }
  1737.     dd.msmoved = 1;
  1738.     if(o.isWindow){
  1739.         var p=dd.getPadding();
  1740.         var d_w, d_h;
  1741.         var prevW=o.w;
  1742.         var prevH=o.h;
  1743.         if(o.resizeDir=="l" || o.resizeDir=="tl" || o.resizeDir=="bl"){
  1744.             if((d_w = dd.limW(2*dd.ofx-(dd.inWndW(dd.ofx+dd.e.x)-o.x)))!=prevW){
  1745.                 if(dd.e.x<p.left) {d_w-=p.left-dd.e.x;dd.e.x=p.left}
  1746.                 if(dd.e.y<p.top) {d_h-=p.top-dd.e.y;dd.e.y=p.top}
  1747.                 o.moveTo(dd.e.x,o.y);
  1748.                 dd.ofx = o.x+d_w-dd.e.x;
  1749.             }
  1750.         }
  1751.         else if (o.resizeDir=="r" || o.resizeDir=="tr" || o.resizeDir=="br"){
  1752.             d_w = dd.limW(dd.inWndW(dd.ofx+dd.e.x)-o.x);
  1753.         }
  1754.         else var d_w = o.w;
  1755.  
  1756.         if(o.resizeDir=="tl" || o.resizeDir=="t" || o.resizeDir=="tr"){
  1757.             if((d_h = dd.limH(2*dd.ofy-(dd.inWndH(dd.ofy+dd.e.y)-o.y)))!=prevH){
  1758.                 o.moveTo(o.x,dd.e.y);
  1759.                 dd.ofy = o.y+d_h-dd.e.y;
  1760.             }
  1761.         }
  1762.         else if (o.resizeDir=="br" || o.resizeDir=="b" || o.resizeDir=="bl"){
  1763.             d_h = dd.limH(dd.inWndH(dd.ofy+dd.e.y)-o.y);
  1764.         }
  1765.         else d_h = o.h;
  1766.         d_w=Math.min(d_w,dd.getWndW()-p.right-o.x)
  1767.         d_h=Math.min(d_h,dd.getWndH()-p.bottom-o.y)
  1768.  
  1769.         // Prevent 0 width or height for windows
  1770.         if(d_w<=0) d_w=false; if(d_h<=0) d_h=false;
  1771.     }
  1772.     // If object has rotation, stretch and rotate according to difference between current center->mouse vector and pick cener->mouse vector
  1773.     else if(o.rot){
  1774.         var f,nV=dd.rotVect(o);
  1775.         f=nV['d']/o.pickRotVect['d'];
  1776.         o.resizeTo(f*o.pickW,f*o.pickH)
  1777.         o.moveTo(o.pickX-(o.w-o.pickW)/2, o.pickY-(o.h-o.pickH)/2)
  1778.         o.rotTo(o.pickAngle+nV['a']-o.pickRotVect['a'])
  1779.     }
  1780.     else{
  1781.         var d_w = dd.limW(dd.inWndW(dd.ofx+dd.e.x)-o.x), d_h;
  1782.         if(!dd.whratio) d_h = dd.limH(dd.inWndH(dd.ofy+dd.e.y)-o.y);
  1783.         else
  1784.         {
  1785.             d_h = dd.limH(dd.inWndH(Math.round(d_w/dd.whratio)+o.y)-o.y);
  1786.             d_w = Math.round(d_h*dd.whratio);
  1787.         }
  1788.     }
  1789.     // Do resize (except if rot, resi
  1790.     if(!o.rot) dd.reszTo(d_w, d_h);
  1791.     if(W.my_ResizeFunc) my_ResizeFunc();
  1792.     if(o.resizeFunc) o.resizeFunc();
  1793.     return MOUSE_MOVED(d_ev);
  1794. }
  1795.  
  1796. // Script load monitoring
  1797. if(W.lFunc) lFunc('wz_dragdrop',25);
  1798.  
  1799. /**
  1800.  * DROP FUNCTION
  1801.  */
  1802. function DROP(d_ev)
  1803. {
  1804.     if(dd.disabled) return true;
  1805.     if(d_ev){
  1806.         dd.e = new dd.evt(d_ev);
  1807.         updateMousePosition(d_ev);
  1808.     }
  1809.  
  1810.     var o=dd.obj;
  1811.     if(o){
  1812.         // Set drag time (overwritten when object stops if inertia)
  1813.         o.dragTime=(new Date()).getTime()-o.pickDate;
  1814.         // Store mouse coordinates
  1815.         o.mDropX=mouseX; o.mDropY=mouseY;
  1816.         o.mdx=o.mDropX-o.mPickX; o.mdy=o.mDropY-o.mPickY;
  1817.  
  1818.         if(o.is_dragged)
  1819.         {
  1820.             if(!o.is_image) dd.getWH(o);
  1821.         }
  1822.         else if(dd.n4)
  1823.         {
  1824.             if(o.is_image)
  1825.             {
  1826.                 dd.n4RectVis(0);
  1827.                 o.resizeTo(o.w, o.h);
  1828.             }
  1829.         }
  1830.  
  1831.  
  1832.         dd.setMovHdl(MOUSE_MOVED);
  1833.         //dd.setMovHdl(OVER);
  1834.         dd.setUpHdl(dd.upFunc);
  1835.         if(dd.db) dd.db.onselectstart = null;
  1836.         o._setOpaRel(1.0);
  1837.         o._setCrs(o.cursor);
  1838.         if(!o.isWindow) dd.embedVis('visible');
  1839.         o._resetZ();
  1840.         if(d_ev) dd.e = new dd.evt(d_ev);
  1841.         my_DropFunc();
  1842.  
  1843.         if(o.dropFunc) o.dropFunc();
  1844.         dd.msmoved = o.is_dragged = o.is_resized = dd.whratio = 0;
  1845.  
  1846.         dd.obj = null;
  1847.     }
  1848.  
  1849.     dd.setDwnHdl(PICK);
  1850. }
  1851. function KDOWN(d_e){
  1852.     updateMousePosition(d_e);
  1853.     if(dragInProgress && dd.obj && dd.obj.ctrlPlus) my_DragFunc();
  1854.     if(dd.kDwnFunc) return dd.kDwnFunc(d_e);
  1855. }
  1856. function KUP(d_e){
  1857.     updateMousePosition(d_e);
  1858.     if(dragInProgress && dd.obj && dd.obj.ctrlPlus) my_DragFunc();
  1859.     if(dd.kUpFunc) return dd.kUpFunc(d_e);
  1860. }
  1861.  
  1862. // Function called on drag event
  1863. function MOUSE_MOVED(d_e){
  1864.     if(dd.disabled) return true;
  1865.     // Update mouseX and mouseY coordinates
  1866.     updateMousePosition(d_e);
  1867.  
  1868.     // Delayed object PICK management
  1869.     if(dd.delayedPickTimeout){
  1870.         if(Math.abs(dd.delayedPickEvt.x-mouseX)+Math.abs(dd.delayedPickEvt.y-mouseY)>2) return PICK('resume');
  1871.     }
  1872.     // if D.onmousemove function set, call it
  1873.     if(dd.moveFunc) return dd.moveFunc(d_e); else return bBrowser=='iPhone';
  1874. }
  1875. function SET_DHTML()
  1876. {
  1877.     dd.moveFunc = D.onmousemove;
  1878.     D.onmousemove=MOUSE_MOVED;
  1879.     D.ontouchmove=MOUSE_MOVED; // iPhone
  1880.     var d_a = arguments, d_ai, d_htm = '', d_o, d_i = d_a.length; while(d_i--)
  1881.     {
  1882.         if(!(d_ai = d_a[d_i]).indexOf('c:')) dd.cursor = d_ai.substring(2);
  1883.         else if(d_ai == NO_ALT) dd.noalt = 1;
  1884.         else if(d_ai == SCROLL) dd.scroll = 1;
  1885.         else if(d_ai == RESET_Z) dd.re_z = 1;
  1886.         else if(d_ai == RESIZABLE) dd.resizable = 1;
  1887.         else if(d_ai == SCALABLE) dd.scalable = 1;
  1888.         else if(d_ai == TRANSPARENT) dd.diaphan = 1;
  1889.         else
  1890.         {
  1891.             d_o = new DDObj(d_ai);
  1892.             dd.addElt(d_o);
  1893.             d_htm += d_o.t_htm || '';
  1894.             if(d_o.oimg && d_o.cpy_n)
  1895.             {
  1896.                 var d_j = 0; while(d_j < d_o.cpy_n)
  1897.                 {
  1898.                     var d_p = new DDObj(d_o.name+d_o.cmd, ++d_j);
  1899.                     dd.addElt(d_p, d_o);
  1900.                     d_p.defz = d_o.defz+d_j;
  1901.                     d_p.original = d_o;
  1902.                     d_htm += d_p.t_htm;
  1903.                 }
  1904.             }
  1905.         }
  1906.     }
  1907.     if (dd.n4 || dd.n6 || dd.ie || dd.op || dd.w3c) D.write(
  1908.         (dd.n4? '<div style="position:absolute;"><\/div>\n'
  1909.         : (dd.op && !dd.op6)? '<div id="OpBlUr" style="position:absolute;visibility:hidden;width:0px;height:0px;"><form><input type="text" style="width:0px;height:0px"><\/form><\/div>'
  1910.         : '') + d_htm
  1911.     );
  1912.     dd.zMin = dd.z = 100;
  1913.     d_i = dd.elements.length; while(d_i--)
  1914.     {
  1915.         dd.addProps(d_o = dd.elements[d_i]);
  1916.         if(d_o.is_image && !d_o.original && !d_o.clone)
  1917.             dd.n4? d_o.oimg.src = spacer : d_o.oimg.style.visibility = 'hidden';
  1918.     }
  1919.  
  1920.     dd.mkWzDom();
  1921.     if(W.onload) dd.loadFunc = W.onload;
  1922.     if(W.onunload) dd.uloadFunc = W.onunload;
  1923.     W.onload = dd.initz;
  1924.     W.onunload = dd.finlz;
  1925.     dd.setDwnHdl(PICK);
  1926.     dd.setKDwnHdl(KDOWN);
  1927.     dd.setKUpHdl(KUP);
  1928.     if(!W.isMainFrame&&W.phpBrowser=='gecko') {if(D.body.onmouseout) bodyOnMouseout=D.body.onmouseout;D.body.onmouseout=my_bodyOut;}
  1929. }
  1930. function ADD_DHTML(d_o,noMkWzDom) // layers only!
  1931. {
  1932.     d_o = new DDObj(d_o);
  1933.     dd.addElt(d_o);
  1934.     dd.addProps(d_o);
  1935.     if(!noMkWzDom) dd.mkWzDom();
  1936. }
  1937.  
  1938.  
  1939.  
  1940.  
  1941. ////////////////////////////////////////////////////////////
  1942. // If not needed, all code below this line may be removed
  1943.  
  1944.  
  1945. // For backward compatibility
  1946. dd.d = document;            // < v. 2.72
  1947. var RESET_ZINDEX = RESET_Z; // < 3.44
  1948. var KEYDOWN_RESIZE = RESIZABLE; // < 4.43
  1949. var CURSOR_POINTER = CURSOR_HAND; // < 4.44
  1950. var NO_SCROLL = '';         // < v. 4.49
  1951.  
  1952.  
  1953.  
  1954.  
  1955. ////////////////////////////////////////////////////////////
  1956. // FUNCTIONS FOR EXTENDED SCRIPTING
  1957. // Use these for your own extensions,
  1958. // or to call functions defined elsewhere
  1959.  
  1960.  
  1961.  
  1962. /* my_PickFunc IS AUTOMATICALLY CALLED WHEN AN ITEM STARTS TO BE DRAGGED.
  1963. The following objects/properties are accessible from here:
  1964.  
  1965. - dd.e: current mouse event
  1966. - dd.e.property: access to a property of the current mouse event.
  1967.   Mostly requested properties:
  1968.   - dd.e.x: document-related x co-ordinate
  1969.   - dd.e.y: document-related y co-ord
  1970.   - dd.e.src: target of mouse event (not identical with the drag drop object itself).
  1971.   - dd.e.button: currently pressed mouse button. Left button: dd.e.button <= 1
  1972.  
  1973. - dd.obj: reference to currently dragged item.
  1974. - dd.obj.property: access to any property of that item.
  1975. - dd.obj.method(): for example dd.obj.resizeTo() or dd.obj.swapImage() .
  1976.   Mostly requested properties:
  1977.     - dd.obj.name: image name or layer ID passed to SET_DHTML();
  1978.     - dd.obj.x and dd.obj.y: co-ordinates;
  1979.     - dd.obj.w and dd.obj.h: size;
  1980.     - dd.obj.is_dragged: 1 while item is dragged, else 0;
  1981.     - dd.obj.is_resized: 1 while item is resized, i.e. if <ctrl> or <shift> is pressed, else 0
  1982.  
  1983. For more properties and details, visit the API documentation
  1984. at http://www.walterzorn.com/dragdrop/api_e.htm (english) or
  1985. http://www.walterzorn.de/dragdrop/api.htm (german)    */
  1986. function my_PickFunc()
  1987. {
  1988.     var o=dd.obj;
  1989.     if(winInertiaTimeout) W.clearTimeout(winInertiaTimeout);
  1990.     winInertiaTimeout=false;
  1991.  
  1992.     if(tooltipShown) tooltipDestroy();
  1993.  
  1994.     dragInProgress=true;
  1995.  
  1996.     /* out of overflow:scroll/hidden div */
  1997.     if(o.detachFromParent) {
  1998.         var node=o.div;
  1999.         var tmpDragNode=node.cloneNode(true); // clone staying at node's original location
  2000.         tmpDragNode.setAttribute('id','tmpDragNode');
  2001.         tmpDragNode.style.visibility='hidden';
  2002.         node.parentNode.insertBefore(tmpDragNode,node);
  2003.         // attach item to body or to dragDetach item
  2004.         if(!dgi('dragDetach')) {
  2005.             var ddNode=D.createElement("div");
  2006.             ddNode.id="dragDetach";
  2007.             ddNode.style.position="absolute";ddNode.style.top=0;ddNode.style.left=0;ddNode.style.zIndex=10000;
  2008.             D.body.appendChild(ddNode);
  2009.         }
  2010.         dgi('dragDetach').appendChild(node);
  2011.         dd.recalcItem(o.name);
  2012.     }
  2013.  
  2014.     if(W.preDrag) {if(!preDrag()) return;}
  2015.  
  2016.     if(o.isWindow) winPicked();
  2017.  
  2018.     // Check onpick property of dragged item
  2019.     for(var i=0;i<o.div.attributes.length;i++) {
  2020.         if(o.div.attributes[i].name.toLowerCase()=='onpick') eval(o.div.attributes[i].value);
  2021.     }
  2022.  
  2023.     dragCancelOnclick=false;
  2024.  
  2025.     if(o.detachFromParent) o.moveTo(
  2026.         o.detachOffsetX + (o.vertical? o.x : dd.ofx+dd.e.x-o.w)- o.offsetX,
  2027.          o.detachOffsetY + (o.horizontal? o.y : dd.ofy+dd.e.y-o.h)- o.offsetY
  2028.     );
  2029.     else o.moveTo(
  2030.         o.detachOffsetX + (o.vertical? o.x : dd.maxOffX(dd.inWndW(dd.ofx+dd.e.x)-o.w))- o.offsetX,
  2031.          o.detachOffsetY + (o.horizontal? o.y : dd.maxOffY(dd.inWndH(dd.ofy+dd.e.y)-o.h))- o.offsetY
  2032.     );
  2033.     // Recompute rect of receiverOnly objects
  2034.     drec.computeRect();
  2035. }
  2036.  
  2037. /* my_DragFunc IS CALLED WHILE AN ITEM IS DRAGGED
  2038. See the description of my_PickFunc above for what's accessible from here. */
  2039. function my_DragFunc(launchedItem){
  2040.     var nt=(new Date()).getTime(),bounceCushion=3,gravity=0,padding=W.winPadding;
  2041.     var o=dd.obj;
  2042.     if(!launchedItem){
  2043.         o.lpdx=o.x-o.lpx;
  2044.         o.lpdy=o.y-o.lpy;
  2045.         o.lpda=o.angle-o.lpa;
  2046.         o.lpx=o.x;o.lpy=o.y;o.lpa=o.angle;
  2047.         if(nt>o.lpDate) o.lpdt=nt-o.lpDate;
  2048.         o.lpDate=nt;
  2049.         if(mouseEvt.e.ctrlKey && o.ctrlPlus) {
  2050.             if(!dd.elements.ctrlPlusItem){
  2051.                 var ctrlPlusItem=D.createElement("div");
  2052.                 ctrlPlusItem.id='ctrlPlusItem';
  2053.                 ctrlPlusItem.style.position='absolute';
  2054.                 ctrlPlusItem.innerHTML='<img alt="" src="/gfx/plus.gif">';
  2055.                 D.body.appendChild(ctrlPlusItem);
  2056.                 ADD_DHTML('ctrlPlusItem');
  2057.             }
  2058.             dd.elements.ctrlPlusItem.show();
  2059.             //dd.elements.ctrlPlusItem.moveTo(o.x-4,o.y-4)
  2060.             dd.elements.ctrlPlusItem.moveTo(o.x-12,o.y-12)
  2061.         }
  2062.         else if(o.ctrlPlus && dd.elements.ctrlPlusItem) dd.elements.ctrlPlusItem.hide();
  2063.     }
  2064.     // Launched item
  2065.     else{
  2066.         var b;
  2067.         if(dd.elements[launchedItem]==null) return;
  2068.  
  2069.         b=W.dragNLaunchFriction||0.005;
  2070.  
  2071.         prevObj=o;
  2072.         o=dd.obj=dd.elements[launchedItem];
  2073.         
  2074.         // If object or all objects may not be launched, abort
  2075.         if(!o.isLaunched && (o.noLaunch || dd.noLaunch)) return;
  2076.         
  2077.         o.isLaunched=1;
  2078.  
  2079.  
  2080.         if(o.lpdt==0){o.lpdt=1;    o.lpdx=0; o.lpdy=0;}
  2081.  
  2082.         // Scene borders
  2083.         var minX=0; if(o.maxoffl!=-1) minX=Math.max(0,o.defx-o.maxoffl);
  2084.         var maxX=(W.winMe)?winMe.getInnerWidth():D.body.scrollWidth; if(o.maxoffr!=-1) maxX=o.defx+o.maxoffr+o.w;
  2085.         var minY=0; if(o.maxofft!=-1) minY=Math.max(0,o.defy-o.maxofft);
  2086.         var maxY=(W.winMe)?winMe.getInnerHeight():D.body.scrollHeight; if(o.maxoffb!=-1) maxY=o.defy+o.maxoffb;
  2087.  
  2088.         if(padding){
  2089.             minX+=padding['left'];
  2090.             maxX-=padding['right'];
  2091.             minY+=padding['top'];
  2092.             maxY-=padding['bottom'];
  2093.         }
  2094.  
  2095.         // Gravity
  2096.         o.lpdy+=gravity*o.lpdt;
  2097.  
  2098.         // speeds
  2099.         var vx=(o.lpdx/o.lpdt);
  2100.         var vy=(o.lpdy/o.lpdt);
  2101.         var va=(o.lpda/o.lpdt);
  2102.         var dt=nt-o.lpDate; o.lpDate+=dt;
  2103.  
  2104.         var dv=Math.exp(-1.0*b*dt)
  2105.         o.lpdx*=dv;
  2106.         o.lpdy*=dv;
  2107.         o.lpda*=dv;
  2108.  
  2109.         var dx=vx*(1-dv)/b;
  2110.         var dy=vy*(1-dv)/b+gravity*dt;
  2111.  
  2112.         var nx=o.lpx+dx;
  2113.         var ny=o.lpy+dy;
  2114.  
  2115.         // Bounce
  2116.         var prc=1;
  2117.         if(o.bounce && (nx<minX || nx+o.w>maxX)){
  2118.             if(nx<minX) prc=(minX-o.lpx)/dx; else prc=(maxX-o.lpx-o.w)/dx;
  2119.             prc=(prc+(1-prc)/bounceCushion);
  2120.             dx*=prc; dy*=prc;
  2121.             if(nx<minX) nx=2*minX-(o.lpx+dx); else nx=nx=2*maxX-(o.lpx+dx)-2*o.w;
  2122.             ny=o.lpy+dy;
  2123.             o.lpdx=-o.lpdx/bounceCushion;
  2124.             o.lpdy=o.lpdy/bounceCushion;
  2125.             if(o.rot) o.lpda+=o.lpdy;
  2126.         }
  2127.         if(o.bounce && (ny<minY || ny+o.h>maxY)){
  2128.             if(ny<minY) prc=(minY-o.lpy)/dy; else prc=(maxY-o.lpy-o.h)/dy;
  2129.             prc=(prc+(1-prc)/bounceCushion);
  2130.             dy*=prc; dx*=prc;
  2131.             if(ny<minY) ny=2*minY-(o.lpy+dy); else ny=ny=2*maxY-(o.lpy+dy)-2*o.h;
  2132.             nx=o.lpx+dx;
  2133.             o.lpdy=-o.lpdy/bounceCushion;
  2134.             o.lpdx=o.lpdx/bounceCushion;
  2135.             if(o.rot) o.lpda-=o.lpdx;
  2136.         }
  2137.  
  2138.         o.lpx=nx;
  2139.         o.lpy=ny;
  2140.         o.moveTo(nx,ny);
  2141.         if(o.rot && o.lpda) o.rotBy(o.lpda);
  2142.         dd.elements[launchedItem]=o;
  2143.     }
  2144.     if(W.duringDrag) duringDrag();
  2145.  
  2146.  
  2147.     if(wl) wl.autoScrollDivs.check();
  2148.     if(o.notDroppable) return;
  2149.  
  2150.     var dropTarget=null,receiverOnlyTarget;
  2151.     if(!(receiverOnlyTarget=o.receiverOnlyGetEltBelow(0,1))) dropTarget = o.getEltBelow();
  2152.  
  2153.     /* unhighlight drop target */
  2154.     if(cDT!=null && cDT!=dropTarget){
  2155.         if(cDT.transparentReceiver) cDT.setOpacity(1); else cDT.div.className="dropTarget";
  2156.         cDT=null;
  2157.     }
  2158.     /* unhighlight receiver only target */
  2159.     if(drec.currentTarget!=null && drec.currentTarget!=receiverOnlyTarget) drec.unhighlight();
  2160.  
  2161.     /* highlight drop target */
  2162.     if(dropTarget != null && dropTarget.receiver && !cDT && o!=dropTarget) {
  2163.         cDT=dropTarget;
  2164.         if(cDT.transparentReceiver) cDT.setOpacity(0.5);
  2165.         else cDT.div.className="dropTargetOver";
  2166.     }
  2167.     /* highlight receiver-only target */
  2168.     if(receiverOnlyTarget != null && receiverOnlyTarget!=drec.currentTarget) drec.highlight(receiverOnlyTarget);
  2169.  
  2170.     if(launchedItem){
  2171.         // reset drag time
  2172.         o.dragTime=(new Date()).getTime()-o.pickDate;
  2173.         if(Math.abs(vx)<0.03 && Math.abs(vy) <0.03) o.isLaunched=0;
  2174.         var va=o.lpda; if(isNaN(va)) va=0;
  2175.         o=dd.obj=prevObj;
  2176.  
  2177.         // Launched item stops
  2178.         if(Math.abs(vx)<0.03 && Math.abs(vy) <0.03 && Math.abs(va)<1) my_DropFunc(launchedItem);
  2179.         else winInertiaTimeout=W.setTimeout('my_DragFunc("'+launchedItem+'")', 20);
  2180.     }
  2181. }
  2182.  
  2183.  
  2184.  
  2185.  
  2186. /* my_ResizeFunc IS CALLED WHILE AN ITEM IS RESIZED
  2187. See the description of my_PickFunc above for what's accessible from here. */
  2188. function my_ResizeFunc(){
  2189.     var o=dd.obj;
  2190.     resizeInProgress=true;
  2191.     if(o.isWindow){
  2192.         if(o.w>dd.getWndW() || o.h>dd.getWndH()){
  2193.             o.resizeTo(Math.min(o.w>dd.getWndW()),Math.min(o.h>dd.getWndH()));
  2194.         }
  2195.         if(o.x<0 || o.y<0) o.moveTo(Math.max(0,o.x), Math.max(0,o.y));
  2196.         win(o.name).resizeMask();
  2197.     }
  2198. }
  2199. /* Called on resize complete */
  2200. function my_ResizedFunc(){if(W.resizeComplete) resizeComplete();}
  2201.  
  2202. /* THIS ONE IS CALLED ONCE AN ITEM IS DROPPED
  2203. See the description of my_PickFunc for what's accessible from here.
  2204. Here may be investigated, for example, what's the name (dd.obj.name)
  2205. of the dropped item, and where (dd.obj.x, dd.obj.y) it has been dropped... */
  2206. function my_DropFunc(launchedItem)
  2207. {
  2208.     var o=dd.obj;
  2209.     if(dd.elements.ctrlPlusItem) dd.elements.ctrlPlusItem.hide();
  2210.     drec.unhighlight();
  2211.     if(!o || o.inertia){
  2212.         if(!launchedItem){
  2213.             var dt=((new Date()).getTime() - o.lpDate);
  2214.             if(dt < ((W.dragNLaunchThreshold!=undefined)?dragNLaunchThreshold:100) && o.lpdt>0){ // start launch
  2215.                 dragCancelOnclick=true;
  2216.                 my_DragFunc(o.index);
  2217.                 return;
  2218.             }
  2219.         }
  2220.         else{
  2221.             prevObj=dd.obj;
  2222.             o=dd.obj=dd.elements[launchedItem];
  2223.             dragCancelOnclick=false;
  2224.         }
  2225.     }
  2226.  
  2227.     /* out of overflow:scroll/hidden div */
  2228.     if(o.detachFromParent) {
  2229.         dgi('tmpDragNode').parentNode.insertBefore(o.div,dgi('tmpDragNode'));
  2230.         dgi('tmpDragNode').parentNode.removeChild(dgi('tmpDragNode'));
  2231.         dd.recalcItem();o.moveTo(o.vertical? o.x : dd.maxOffX(dd.inWndW(dd.ofx+dd.e.x)-o.w),o.horizontal? o.y : dd.maxOffY(dd.inWndH(dd.ofy+dd.e.y)-o.h));
  2232.     }
  2233.  
  2234.     dragInProgress=false;
  2235.     if(resizeInProgress) my_ResizedFunc()
  2236.     resizeInProgress=false;
  2237.  
  2238.     var DTClass;
  2239.     if(o.dragTime > dragMinTimeForPreDrop && W.preDrop) preDrop();
  2240.     if(o.div.onmouseout) o.div.onmouseout();
  2241.  
  2242.     // Restore class
  2243.     if(o.dragClass) $(o.div).e.className().remove('dragged');
  2244.  
  2245.     // Check ondrop property of dragged item
  2246.     if(Math.pow(o.x - o.defx,2) + Math.pow(o.y - o.defy, 2) > 0){
  2247.         for(i=0;i<o.div.attributes.length;i++) {
  2248.             if(o.div.attributes[i].name.toLowerCase()=='ondrop') eval(o.div.attributes[i].value);
  2249.         }
  2250.     }
  2251.     if(o.isWindow) winDropped();
  2252.     if(o.isIcon) iconDropped();
  2253.  
  2254.     // Get drop target
  2255.     var dropTarget = null, receiverOnlyTarget=null;
  2256.     if(W.dropFunction && !o.notDroppable)
  2257.         if(!(receiverOnlyTarget=o.receiverOnlyGetEltBelow())) dropTarget=o.getEltBelow();
  2258.  
  2259.     // Drag distance
  2260.     var d2;
  2261.     if(o.inertia)
  2262.         d2=Math.pow(o.x - o.pickX,2) + Math.pow(o.y - o.pickY, 2);
  2263.     else
  2264.         d2=Math.pow(o.mdx,2) + Math.pow(o.mdy, 2);
  2265.  
  2266.     /**
  2267.      * Check if dropped over a target
  2268.      */
  2269.     if(W.dropFunction!=false && !o.notDroppable && o.dragTime > 300 && d2>20){
  2270.         // If a droppable object is dropped over a receiver (drop target) and a drop function has been defined, launch drop function
  2271.         if(dropTarget && dropTarget.receiver) {
  2272.             if(o.name.substr(0,1)=='_') eval('W.dropFunction("'+o.name.substr(1)+'", "'+dropTarget.name+'");');
  2273.             else eval('W.dropFunction("'+o.name+'", "'+dropTarget.name+'");');
  2274.         }
  2275.         // Correct a z-index bug (or implementation issue ?)
  2276.         else if(cDT && cDT.receiver){
  2277.             if(o.name.substr(0,1)=='_') eval('W.dropFunction("'+o.name.substr(1)+'", "'+cDT.name+'");');
  2278.             else eval('W.dropFunction("'+o.name+'", "'+cDT.name+'");');
  2279.         }
  2280.         // else if a receiverOnly target is found
  2281.         else if(receiverOnlyTarget && receiverOnlyTarget.id){
  2282.             if(o.name.substr(0,1)=='_') eval('W.dropFunction("'+o.name.substr(1)+'", "'+receiverOnlyTarget.id+'");');
  2283.             else eval('W.dropFunction("'+o.name+'", "'+receiverOnlyTarget.id+'");');
  2284.         }
  2285.     }
  2286.  
  2287.     var srcObj;
  2288.     if(o.is_image)
  2289.         srcObj=D.getElementsByName(o.name)[0];
  2290.     else
  2291.         srcObj=dgi(o.name);
  2292.  
  2293.     // if object not moved, do click if onclick attribute
  2294.     if((d2 < 65 && (o.dragTime < 350)) || (o.dragTime < 100)){
  2295.         dd.dragClick=1;
  2296.         dragCancelOnclick=0;
  2297.         if(srcObj && srcObj.attributes['onclick']) eval(srcObj.attributes['onclick'].nodeValue);
  2298.         dd.dragClick=0;
  2299.     }
  2300.     else{
  2301.         if(!o.is_image && srcObj && srcObj.attributes['onclick']) dragCancelOnclick=true;
  2302.     }
  2303.     /* un-highlight drop target */
  2304.     if(cDT!=null){
  2305.         if(cDT.transparentReceiver) cDT.setOpacity(1); else cDT.div.className="dropTarget";
  2306.         cDT=null;
  2307.     }
  2308.  
  2309.     // Return to position
  2310.     if(o.elastic || o.elasticTmp){
  2311.         o.elasticTmp=0;
  2312.         // Animation
  2313.         if(!o.noAnim && !o.cancelAnim) {
  2314.             dd.elasticAnim(o.name);
  2315.         }
  2316.         // No animation
  2317.         else {
  2318.             if(o.cancelAnim) o.cancelAnim=0;
  2319.             o.moveTo(o.defx, o.defy);
  2320.             dd.recalcItem();
  2321.             o.released();
  2322.         }
  2323.     }
  2324.     else {
  2325.         o.defx=o.x;o.defy=o.y;
  2326.         dd.recalcItem();
  2327.         o.released();
  2328.     }
  2329.  
  2330.     //
  2331.     if(o.dropFuncInertia) o.dropFuncInertia();
  2332.  
  2333.     // Reset previous o
  2334.     if(launchedItem) dd.obj=prevObj;
  2335. }
  2336.  
  2337. function my_DragClearAllItems(){
  2338.     while(dd.elements.length>0) dd.elements[0].del(true);
  2339.     dd.recalc();
  2340. }
  2341.  
  2342. function my_winResize(){if(W.bodyResized) bodyResized();}
  2343.  
  2344. // Update mouseX and mouseY coordinates
  2345. function updateMousePosition(d_e){
  2346.     var dt,newT;
  2347.     //if(this.t==undefined) alert('u')
  2348.     mouseEvt = new dd.evt(d_e);
  2349.     if(mouseEvt.x || mouseEvt.y){
  2350.         newT=wl.chrono.microtime();
  2351.  
  2352.         if(mousePosT!=undefined){
  2353.             //dgi('debug').innerHTML=newT-mousePosT;
  2354.             if(dt=(newT-mousePosT)){
  2355.                 mouseVX=1000*(mouseEvt.x-mouseX)/dt
  2356.                 mouseVY=1000*(mouseEvt.y-mouseY)/dt
  2357.             }
  2358.         }
  2359.         else{
  2360.             mouseVX=mouseVY=0;
  2361.         }
  2362.         mousePosT=newT;
  2363.         mouseX=mouseEvt.x;
  2364.         mouseY=mouseEvt.y;
  2365.     }
  2366. }
  2367. // Monitor mouse position even outside of drag & drop events
  2368. function monitorMousePosition(){D.onmousemove=updateMousePosition}
  2369. var bodyOnMouseout=0;
  2370. function my_bodyOut(){
  2371.     /*
  2372.     if(bodyOnMouseout) bodyOnMouseout;
  2373.     if(dragInProgress && dd.obj && !(dd.scroll || dd.obj.scroll)) DROP(false);
  2374.     */
  2375. }
  2376.  
  2377. // Script load monitoring
  2378. if(W.lFunc) lFunc('wz_dragdrop',25);